Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Input Hidden usage
Message
 
À
29/05/2009 14:43:09
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
ASP.NET
OS:
Windows XP SP2
Application:
Web
Divers
Thread ID:
01402665
Message ID:
01402685
Vues:
43
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform