Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I would like to know if there is a way to on a user control , if an Exception is thrown if it is possible to instead of showing an error page for the page to continue loading but show a Message in the place of where the user control is supposed to be

What I am attempting is a little bit more complex than try catch, this has to be generic for all un-handled exceptions, so if for instance a data-source control lost connection to a database. I also know about global error handling in gobal.asax , but I am aiming to individually handle errors on individual user controls.
Posted
Updated 30-Nov-11 3:01am
v3

If I understood your question correctly, you may use "Try-Catch" block to catch your Exception and then display appropriate message to End-User.

Have a look at below link for more information.
http://msdn.microsoft.com/en-us/library/0yd65esw%28v=VS.100%29.aspx
 
Share this answer
 
Comments
L Viljoen 30-Nov-11 8:33am    
What I am attempting is a little bit more complex, this has to be generic for all unhandled exceptions, so if for instance a datasource countrol lost connection to a database. I also know about global error handling in gobal.asax , but still I am aiming for something more elegant.
Yes, there is a way. It's called Exception Handling. You write code to handle the Exceptions that may be thrown and display a message.
 
Share this answer
 
Comments
L Viljoen 30-Nov-11 8:31am    
Yes we all know try catch ... and so on , what I am attempting is a little bit more complex, this has to be generic for all unhandled exceptions, so if for instance a datasource lost connection to a database.

I also know about global error handling in gobal.asax , but still I am aiming for something more elegant.
[no name] 30-Nov-11 8:47am    
The better you explain yourself initially the better the answers may be.

If you only want to handle exceptions in your user control then use the try/catch you are familiar with. If you want generic, then the global.asax is the place to put it. If you want your user control to handle all exceptions on a page then its not going to happen.
L Viljoen 30-Nov-11 8:55am    
try catch is coding 101, but yes in future i will explain my problem better.

And no i don't ant my user control to handle all error on a page , as explained i only want to suppress errors on a user control individually.
fjdiewornncalwe 30-Nov-11 14:52pm    
+5. Cheeky but valid. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900