Handling Exceptions in User Controls

R

ratnikov.alexander

Hi all. I'd like to replace user control( if it loads with exception
or fires exception during execution) with a friendly message. This
strategy is used in dotnetnuke but there they load controls in code but
i have to add them manually to aspx pages(historically). Can i somehow
handle it? For instance on render event?
 
K

Karl Seguin [MVP]

I think ur best bet will be to look into the Page_Error event of the user
control itself. It's like Page_Load, but fires when an exception occurs.
I'm not sure what you are able to do, but you might potentially be able to
do:

sub Page_Error(..)
Response.Write("Sorry, the module could not be loaded")
end sub
 
R

ratnikov.alexander

Thanks for reply. I'm already using Page_Error but it doesnt actually
handle the exception. After it is called the page life cycle breaks,
the page is not rendered and you see the error page. The problem is
within exceptions occured in oninit, page_load and so on events
happened in child controls because i cant wrape it with try catch. It's
possible to if the controls are loaded dynamically but if they are
placed on the page i dont know the solution.
Any ideas are welcome. :)

Karl Seguin [MVP] пиÑал(а):
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top