To run JavaScript from code behind follow the next steps:1. Set the Body tag in your page/master page:
<body runat="server" id="MyBody">
2. Write the script tag in your page:
<script src="MyFunction.js" type="text/javascript"></script>
3. In the code behind attach the onload attribute to the body tag:
protected void Page_Load(object sender, EventArgs e) { MasterPageBodyTag = (HtmlGenericControl)Page.Master.FindControl(“MyBody”); MasterPageBodyTag.Attributes.Add(“Onload”, “MyFunction()”); }

C# in Depth, 3rd EditionBest VPN app