Hi Laurent,
I tried and it did not work.
By following your example, I tried to handle the exception by putting
similar code on Page_PreInit, Page_Init, Page_PreRender, Page_Load.
Nothing worked.
By stepping into the code, it seems that it was executed in the following
order:
WebPage PreInit, WebPage Init, Control Load (where I throw and exception).
The code still blows up with an "Unhandled Exception"
I guess I'm still confused with the lifecycle and what's calling what on
ASP.NET.
"Laurent Bugnion" <ga*********@bluewin.chwrote in message
news:OY**************@TK2MSFTNGP03.phx.gbl...
Hi,
Fernando Chilvarguer wrote:
>I have a very simple test page that the only thing it does is render a
control.
This control generates and throws an error.
I need to catch the error on my ASPX page but I can't figure out where to
put my try/catch block to make it work.
Any ideas?
Thanks,
Fernando
Not tested: The controls are rendered in the Render method of the Page
class. In your own page, which is derived from the base Page class, you
should be able to do that:
protected override void Render( HtmlTextWriter writer )
{
try
{
base.Render( writer );
}
catch ( Exception ex )
{
// Deal with exception
}
}
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch