Monday, January 3, 2011

Resolving Body OnLoad Error BC30456 when runat="Server"

Having trouble loading a javascript function with your body onload call with ASP.NET? If you're getting the Compiler Error Message: BC30456: 'myFunction' is not a member of 'ASP.myMaster', then chances are you've probably set your body to runat="server".


Luckily, there is a way to keep your body running at the server level and a javascript function to the onload method.

First, remove the onload attribute from your body tag:
<body runat="server" id="masterbody">

Now, in the code behind your page or in my case, the master page, add the following code:
masterbody.Attributes.Add("onload", "javascript:myFunction();")

0 comments:

Post a Comment