Monday, March 26, 2012

Setting server control value from Javascript

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
KevUse a textbox control with EnableViewState = True; write the values to
it in javascript; then during your page.postback, you can read the
values...
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

"Mantorok" wrote:

> 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
>

0 comments:

Post a Comment