473,563 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HiddenField value not valid

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
Oct 13 '06 #1
3 1961
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.

"sklett" <s@s.comwrote in message
news:O8******** ******@TK2MSFTN GP05.phx.gbl...
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
Oct 13 '06 #2

Make sure its runat=server

Else, its just a "client side" only object.

"sklett" <s@s.comwrote in message
news:O8******** ******@TK2MSFTN GP05.phx.gbl...
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


Oct 13 '06 #3
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 <formtag.

Robert Haken [MVP ASP/ASP.NET]
HAVIT, s.r.o., www.havit.cz
http://knowledge-base.havit.cz
Oct 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4660
by: Kevin Blount | last post by:
Here's the code I tried, and found it failed... <form runat="server" method="post" name="CreditCardForm" id="CreditCardForm"> <% foreach (object item in Request.Form) { if (item.ToString().IndexOf("__") != 0) { //Response.Write(item + " = " + Request.Form +
3
6846
by: Jeff | last post by:
Hey ASP.NET 2.0 Below you see the code I'm having problem with. In the Open_Message event/method I want to get the value of the HiddenField at the row in the repeater control I clicked.... my goal is to get the id (not a control Id, but an id related to a database record) of a row in the repeater control. I don't want to use Get... I've...
1
1485
by: Milkstr | last post by:
I have a repeating region with a hiddenfield on each line, i want to start a counter in my reapeating reagion so that the hiddenfield becomes unique on each line. So that is the reapeating region goe to say 10 records i actually have 10 hiddenfields with unique names. I thought i could just set a variable at the start of the loop that increments...
1
3434
by: RSH | last post by:
I have a situation where I have a user control (Called TopOrangeMenu) that has an Hidden HTML Field called "txtU" I am trying to get at the value of that hidden field control from within the User Control. Hidden Field Control as it apears in the HTML of the User Control: <INPUT id="txtU" type="hidden" runat="server"> Trace Output...
8
2345
by: Efi Merdler | last post by:
Hi, In my code I'm doing some xml transformation, at the end I receive a fully transformed html file. I'm setting the Value property of an hidden field control to have the content of this html file. In the debugger I can see that the control contains the value correctly, however when the page is displayed in a browser all < symbols are...
5
2396
by: hharry | last post by:
Hello All, I am trying to make use the HiddenField server control to make a server-side variable visible to a client script. I set the value of the HiddenField inside of the Page_Load event. protected void Page_Load(object sender, EventArgs e) { this.myHiddenField.Value = myVar; }
1
2039
by: KBTibbs | last post by:
My ASP.NET page generates some HTML, then sticks it into a hiddenfield so a javascript can access it and write it to a popup window. I had to disable validation for this page, as HTML inside a field triggers ASP.NET's cross-site scripting security. Now, this was all working well and good until I changed my navigation menus from plain images...
1
4542
by: win | last post by:
I've created a formview and bind the columns. The column ModifyUser should not be be displayed so that I've modified from Textbos to HiddenField. How can I change the bind value of a Hiddenfield and update the formview? Thank you
7
11498
by: imbirek8 | last post by:
Hi! I would like to write something in Javascript to HiddenField: <asp:HiddenField ID="hiddenMy" runat="server" Value="" /> And in the code behind read this value. But this HiddenField is in user control. I use this control in many pages and in every page this field has different value.. I don't know why, but it's error when I do: var ...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.