Hi,
I am wondering what is the best way to display exceptions in ASP.net. Do I have to this on a web page or is there a way to display custom exceptions in a message box like on windows forms?
What we did for the sql exceptions we wanted to display was have a label on each webform called lblError (or whatever you want to call it).
Then, if a sql exception bubbled its way back up the form, it was caught, and the label's text property was assigned to somethign like this:
"<Script>javascript:alert('" & err.message & '"</Script>"
This would cause an alert box to appear with the error message on the postback.
Note: we also had to set lblError.Text = "" in the page load so that it would reset after the postback (otherwise the box would keep popping up over and over again).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.