Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Input Hidden usage
Message
 
To
29/05/2009 14:43:09
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows XP SP2
Application:
Web
Miscellaneous
Thread ID:
01402665
Message ID:
01402685
Views:
44
>Hi All,
>
>When I put a hidden field in an ASP.NET page like this does it need to be inside a form element? Can it just go inside the Content place holder?

Yes. But even in a content place holder, the master page will normally have the content embedded in a form tag. So unless you've removed it from your master page, it should be there.

You don't have to use the named form syntax, you can access it via the form collection:
var control = document.forms[0].elements["hdnIsNew"];
The one issue you may have is that, when the script is run it the page hasn't been fully loaded/parsed so it may fail. You can move it to the bottom just above the closing body tag. You can also add an event handler for the windows onload event.

http://www.quirksmode.org/js/events_advanced.html

Make sure you read through the entire thing since IE and other browsers actually do this differently (attachEvent vs addEventListener) . You can handle this pretty easily:
if (window.addEventListener)
   // use addEventListener
else if (window.attachEvent)
   // use attachEvent
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform