Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Hidden Form Field Value Get?

Reply
Thread Tools

Hidden Form Field Value Get?

 
 
xenophon
Guest
Posts: n/a
 
      12-09-2005

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.

 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      12-10-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
How to grant value to a html form hidden field David Jia ASP .Net 5 10-16-2006 10:56 PM
Select box value changes value of hidden field dvwool@ix.netcom.com Javascript 6 04-27-2006 04:38 AM
Hidden Form Field Value not Persisting xenophon ASP .Net 2 12-21-2005 10:05 AM
Pass hidden form field value to another form field to insert in db GavMc ASP General 4 09-22-2005 06:33 PM



Advertisments