views:

110

answers:

2

UserControls in ASP.NET (4.0) inherit from System.Web.UI.UserControl. VisualStudio intellisense suggest OnError as valid 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);
    }
}
+1  A: 

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

Sonic Soul
+1  A: 

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.

error-handling for reusable components?
michl86