WingYip
asked on
ASP.Net body onload event with master pages
Hi
Am using asp.net 3.5 with master pages.
I need to run some javascript to preload some images in the body onload event but I don't need to run this on every page.
The only body tag is in the master page (mp.master) for the site so currently the event runs for all content pages that whose masterpagefile is mp.master.
How can I run js code in the onload event of some pages only.
Can anyone help?
Wing
Am using asp.net 3.5 with master pages.
I need to run some javascript to preload some images in the body onload event but I don't need to run this on every page.
The only body tag is in the master page (mp.master) for the site so currently the event runs for all content pages that whose masterpagefile is mp.master.
How can I run js code in the onload event of some pages only.
Can anyone help?
Wing
ASKER
Have just picked this up again.
I am trying this but no joy as yet. For a start, attributes is not a member of the control class so it doesn't compile. The following compiles but doesnt find the body element.
Dim cBody As HtmlGenericControl = Me.Page.Master.FindControl ("bodyRpMa ster")
cBody.Attributes.Add("onlo ad", "some_jscript")
have set the body in the master to "runat=server" and id to "bodyRpMaster"
I have put all this in the page load event.
Am wondering what to do next
I am trying this but no joy as yet. For a start, attributes is not a member of the control class so it doesn't compile. The following compiles but doesnt find the body element.
Dim cBody As HtmlGenericControl = Me.Page.Master.FindControl
cBody.Attributes.Add("onlo
have set the body in the master to "runat=server" and id to "bodyRpMaster"
I have put all this in the page load event.
Am wondering what to do next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<body runat="server" id="bodyMaster">
and for each page where you want to set the body onload event...
Master.FindControl("bodyMa