开发者

ASP.NET UserControl OnError

开发者 https://www.devze.com 2023-01-02 19:27 出处:网络
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 han

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消