Rudebox.co.nr How To Forums

Rudebox How To Forums - Ask Anything, View How To's
Home­FAQ­Search­Register­Memberlist­Usergroups­Log in
Post new topic   Reply to topicShare | 
 

 How to programmatically add onLoad to Body Tag /Raise Onload

View previous topic View next topic Go down 
AuthorMessage
Admin
Admin


Number of posts: 206
Registration date: 2007-01-01

PostSubject: How to programmatically add onLoad to Body Tag /Raise Onload   Wed Jan 09, 2008 12:52 am

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
Back to top Go down
View user profile http://rudebox.editboard.com
 

How to programmatically add onLoad to Body Tag /Raise Onload

View previous topic View next topic Back to top 
Page 1 of 1

Permissions of this forum:You cannot reply to topics in this forum
Rudebox.co.nr How To Forums :: How To - Myspace / Website /Blog Utilities :: ASP .net-
Post new topic   Reply to topic