Will Clientscript.registerstartupscript Work Only In Forms?
I am trying to execute some javascript code in my aspx code behind file. All the examples i have seen on the internet involves code in handler of a button click... But, for my need
Solution 1:
Yes, as of ASP.NET 2.0[1] the script will not be added to the page unless it contains a form with the runat attribute set to "server":
<formrunat="server">
You don't need to add any controls to the page, so can't you just add the form to your .aspx file? Alternatively, why not just add the call to the script directly to the page? E.g.
<bodyonload="doStuff();">
[1] http://www.haiders.net/post/Rendering-Client-Script-in-ASPNET-20-Behavior-changes.aspx
Post a Comment for "Will Clientscript.registerstartupscript Work Only In Forms?"