Reputation: 2134
Is there a way to universally force a page to error when a usercontrol raises an error? For example, if you write code that will create an error in a usercontrol, like this:
<asp:Label ID="lbl" runat="server" Text='<%# string.Format(("") %>' />
The page will still load like everything is working, but the portion of the page that the usercontrol occupies will contain the error "... ) expected." I want the page to actually error like it normally would if that bad code were on a normal .aspx page. Thanks in advance for any advice.
Upvotes: 1
Views: 910
Reputation: 1062
See How do I catch an exception raised on my ASCX control (not the code-behind)? for some details on this. One suggested solution involves creating an event in your user control that is fired if an exception is caught during the control's RenderChildren method. Then, your parent aspx page can handle the event raised in the ascx.
Upvotes: 1