UserControls in ASP.NET (4.0) inherit from System.Web.UI.UserControl. VisualStudio intellisense suggest OnError as valid开发者_C百科 override of TemplateControl. At runtime .NET ignores this error handling. Only the OnError at Page-Level gets invoked. Did i miss anything or is there a design issue?
public partial class Sample : System.Web.UI.UserControl
{
protected override void OnError(EventArgs e)
{
// Never reach ;o)
base.OnError(e);
}
}
ah.. the elusive OnError
this page sheds some good light on the inner workings of this event:
http://weblogs.asp.net/vga/archive/2003/06/16/8748.aspx
it may be that some exceptions are caught w/out triggering OnError
Why do you want to override OnError? You'd probably be better off by using a try/catch block or subscribing to the Application_Error event.
精彩评论