How we can use the onLoad() event in ASP.Net 2.0 content pages ?
Simple !.
A content page is basicall a page inherited from a MasterPage (.master) in .net framework 2.0. This can be adhieved by either two ways.
1. Javascript function overrideAdd body onLoad() event in the master page and override the function used in the event in the inherited content pages.
Say,
in master page<html>
<head>
<script language=" javascript" type=" text/javascript">
function testonload(){ //an empty function
var x = 'empty';
}
</script>
</head>
.
..
...
....
.....
in content page<asp:content id="Content1" runat="Server" contentplaceholderid="ContentPlaceHolder1">
<script language="javascript" type="text/javascript">
function testonload(prodid, div) {
//client script logic goes here..!!
}
</script>
2. Bind client script to body in code behindGive an id to the body tag of the masgter page and add runat="server" sot that it is available in the code behind.
Now in content pages, add the following code in the page_load event
HtmlGenericControl body = (HtmlGenericControl)Page.Master.FindControl("bodyMaster");
body.Attributes.Add("onload", "toggle('parameters');");
Keep coding,