Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Input Hidden usage
Message
De
29/05/2009 16:55:34
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:
01402707
Vues:
30
>>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
>
Ah, I see the form in the master page and now I get the point. I will try referencing via the form collection like you show. Thank you. It appear when trying to figure this stuff out, if the javascript has an invalid piece of code, it just fails after that point so the effect is it isn't running. If you place a breakpoint after the bad line, it never breaks. If you place it on the bad line you can't step into it to see why or any values. Very challenging to learn this with this behavior.

All my script is the last thing in the file and just above it is the hidden field.

I will read up on the link you posted to see if I can gleam anything from that. At this point I have so many hours in this it is ridiculous. The price for learning. Fortunately I am learning a lot, but still haven't solved this puzzle.
Thanks again Paul
Tim
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform