[thelist] Trapping unhandled exceptions (Errors) in ASP.NET User Controls
aleemb at gmail.com
Wed Jul 23 16:00:19 CDT 2008
After a long stint away from web dev, I have come back to the list with what
else, but a web dev problem. Are Rudy/Jeff still around? I am encountering
an ASP.NET (2.0) problem I'll get straight to it.
Simplified version is that I have a Dashboard.aspx file that iterates
through a directory and dynamically loads each widgets in its own container
(which can be dragged/dropped/minimized etc). Widgets are .ascx files. All
Widgets inherit from BaseWidget which inherits Web.UI.UserControl.
Dashboard.aspx loads widgets in a try/catch block and any compile time
errors are trapped and instead of showing the widget data, the exception
stack is shown so it's all neatly handled and the error is localized within
the widget. The problem is with runtime errors which block the entire
Dashboard even if a single Widget throws a runtime Error.
I would like to be able to capture runtime exceptions in the BaseWidget
class using a generic handler. The UserControl and Page implement ITemplate
which has a .Error event, however it only works for Page, not for
Any suggestions on how to trap any unhandled exceptions for widgets and
display them on the Dashboard within the widget container? I can't enforce
other developers to write their entire widget code in try/catch blocks,
hence the BaseWidget.
"It is not the mountain we conquer but ourselves" -- Sir Edmund Hillary
(1919 - 2008)
More information about the thelist