HiddenField value not valid

  • Thread starter Thread starter sklett
  • Start date Start date
S

sklett

I've added a HiddenField control to my page and some javascript to show it's
value in an alert box when a button is pressed. The value that is displayed
in the alert box is correct, but when I post the form the value for the
HiddenField control is empty.

I'm pretty new to ASP.net so I'm not really sure what could cause this.

I'm using client side javascript to set the value in the HiddenField, not
sure if that matters.

Any ideas?

Thanks for reading,
Steve
 
I am not sure how you access the HiddenField control on the client side.
Remember the ID assigned to the ASP.NET controls on the client side are
different than those used on the server side. Make sure you use the
..ClientID property of the control to get the client side ID for use in
JavaScript.

I've added a HiddenField control to my page and some javascript to show it's
value in an alert box when a button is pressed. The value that is displayed
in the alert box is correct, but when I post the form the value for the
HiddenField control is empty.

I'm pretty new to ASP.net so I'm not really sure what could cause this.

I'm using client side javascript to set the value in the HiddenField, not
sure if that matters.

Any ideas?

Thanks for reading,
Steve
 
I've added a HiddenField control to my page and some javascript to show
it's value in an alert box when a button is pressed. The value that is
displayed in the alert box is correct, but when I post the form the value
for the HiddenField control is empty.

I'm pretty new to ASP.net so I'm not really sure what could cause this.

I'm using client side javascript to set the value in the HiddenField, not
sure if that matters.

Any ideas?

Make sure, the hidden-field is not "disabled" on client-side. Data of
disabled <input>s are not sent with POST.
You can use atribute Trace="true" in <%@ Page %> directive to see what the
POST data are.
Also make sure, that the hidden-field is inside the <form> tag.

Robert Haken [MVP ASP/ASP.NET]
HAVIT, s.r.o., www.havit.cz
http://knowledge-base.havit.cz
 
Back
Top