Substitute User Controls on Failure
Posted
by Brian
on Stack Overflow
See other posts from Stack Overflow
or by Brian
Published on 2009-11-09T20:47:30Z
Indexed on
2010/04/29
15:37 UTC
Read the original article
Hit count: 157
Recently, I had a user control I was developing throw an exception. I know what caused the exception, but this issue got me thinking. If I have a user control throw an exception for whatever reason and I wish to replace that usercontrol with something else (e.g. an error saying, "Sorry, this part of the page broke.") and perhaps log the error, what would be a good way to do it that could be done independently of what the user control is or does (i.e. I'm not saying what the user control does/is, because I want an answer where that is irrelevant).
Code sample:
<asp:TableRow VerticalAlign="Top" HorizontalAlign="Left">
<asp:TableCell>
<UR:MyUserControl ID="MyUserControl3" runat="server" FormatString="<%$ AppSettings:RVUC %>"
ConnectionString="<%$ ConnectionStrings:WPDBC %>" Title="CO" />
</asp:TableCell>
<asp:TableCell>
<UR:MyUserControl ID="MyUserControl4" runat="server" FormatString="<%$ AppSettings:RVUA %>"
ConnectionString="<%$ ConnectionStrings:WPDBA %>" Title="IEAO" />
</asp:TableCell>
</asp:TableRow>
© Stack Overflow or respective owner