Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Hidden Form Field Value Get? (http://www.velocityreviews.com/forums/t115216-hidden-form-field-value-get.html)

xenophon 12-09-2005 10:03 PM

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.


Jeff 12-10-2005 01:04 AM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57