Reputation: 801
I want to bind to the Page PreRender method on at the global.asax level, but for some reason the method is never getting called. My method looks like:
protected void Page_PreRender(object source, EventArgs e)
{
/* do stuff */
}
Am I able to call Page events like this in Global.asax?
Upvotes: 1
Views: 893
Reputation: 66641
The global.asax is derived from HttpApplication class and not contain the Page_PreRender event as you can see on the MSDN reference:
http://msdn.microsoft.com/en-us/library/system.web.httpapplication(VS.90).aspx
If you want to globally capture the PreRender event you can make a different base class for the System.Web.UI.Page
, overwrite this event, and use this class to your pages.
For example
public abstract class BasePage : System.Web.UI.Page
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}
}
and use the BasePage
on your pages
Upvotes: 1