Setting server control value from Javascript

M

Mantorok

Hi all

I have a JS function that sets the value of a textbox, however, after
submitting the page and during server-side execution the textbox's Text
property is blank.

How can I access the textbox's value server-side after it's been set
client-side?

Thanks
Kev
 
J

John.Net

Use a textbox control with EnableViewState = True; write the values to
it in javascript; then during your page.postback, you can read the
values...
 
G

Guest

Hi

Try this, it is working fine for me.
<script language="javascript">
function setvalues()
{
document.forms[0].TextBox1.value="3";
}
</script>
private void Page_Load(object sender, System.EventArgs e)
{
Button1.Attributes.Add("onclick","javascript:setvalues();");
}

private void Button2_Click(object sender, System.EventArgs e)
{
Response.Write(TextBox1.Text.ToString());
}


From
Nirmal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,132
Latest member
TeresaWcq1
Top