![]() |
Hidden Form Field Value Get?
I add a Hidden form field to my asp.net page in the codebehind, the Value peoperty is set to 0 and EnableViewState is set to true. Then I add a LiteralControl with JavaScript that says to set the value to 1. If I set view the value of th ehidden form field in the debugger during the course of a PostBack, the value is still set to 0. Are there any samples of setting a vlaue with JavaScript and reading the new value in ASP.NET? Thanks. |
Re: Hidden Form Field Value Get?
Make sure that in your ASPX code that you include runat="server" in your
Hidden form field declaration, like this: <input id="myHiddenField" type=hidden value="" runat="server"> Then declare it in the code-behind like this: protected System.Web.UI.HtmlControls.HtmlInputHidden myHiddenField; Then you can read the value like this (in code-behind): string hiddenValue = myHiddenField.Value or set the value like this (in code-behind): myHiddenField.Value = "whatever"; And client-side you just refer to the hidden field like you normally would: document.Form1.myHiddenField.value = "whatever"; -HTH "xenophon" <xenophon@online.nospam> wrote in message news:7kvjp19spsvi4nouqhlbunth5o8ei0ktug@4ax.com... > > I add a Hidden form field to my asp.net page in the codebehind, the > Value peoperty is set to 0 and EnableViewState is set to true. Then I > add a LiteralControl with JavaScript that says to set the value to 1. > If I set view the value of th ehidden form field in the debugger > during the course of a PostBack, the value is still set to 0. > > Are there any samples of setting a vlaue with JavaScript and reading > the new value in ASP.NET? > > Thanks. > |
| All times are GMT. The time now is 11:19 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.