Inject onload javascript for asp.net aspx master page

1. Add reference to HtmlControls on top of your cs file

using System.Web.UI.HtmlControls;

2. In your Page_Load function of the .cs file add

((HtmlGenericControl) this.Page.Master.FindControl(“PageBody”)).Attributes.Add(“onload”, “load()”);

3. Make sure your master page BODY has the the matching id from above. in this case:

ID=”PageBody” runat=”server”

4. In your aspx file, add you load function.

Scroll to top
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.