Admin Admin
Number of posts : 216 Registration date : 2007-01-01
| Subject: How to programmatically add onLoad to Body Tag /Raise Onload Tue Jan 08, 2008 5:52 pm | |
| If you can access the tag in the .aspx page make it - Code:
-
<body id="myBody" runat="server"> In The Code Behind add - Code:
-
this.myBody.Attributes.Add("onLoad", "myJavaScript()"); or - Code:
-
HtmlGenericControl myBodyTag = (HtmlGenericControl) myBody; myBodyTag.Attributes.Add("onLoad", "myJavaScript()"); Sometimes you cant access the OnLoad Tag for example if you have a master Page, and trying to access it from a child Page. Then you can use something like this at the bottom or top of the .aspx (Tested) - Code:
-
<iframe onload="myJavaScript()" visible="false" style="display: none" > </iframe>
or In Code (Not Tested) Something like VB.net - Code:
-
CType(Page.Master,MyMasterClassName).Body.ClientID | |
|