Pass Exception Message to label on another page
I’m wondering once I catch an exception, how can I use the exception message in another page?
How can I pass this exception message into a label on another page? In order so I can have the exception message displayed with my own material. What is the best way to go about this?
Example:
Try
'logic in here
Catch ex As Exception
ex.Message 'pass this message of the exception so it can be used in a different page
End Try
Re: Pass Exception Message to label on another page
Create a global variable (ie. errMsg as string).
Then:
Code:
Try
Catch
errMsg=ex.Description
End Try
Re: Pass Exception Message to label on another page
"page" ??? Page or form? ASP.NET or WinForm?
-tg
Re: Pass Exception Message to label on another page
Re: Pass Exception Message to label on another page
That's what I thought... thread needs to be moved to the ASP.NET forum where you'll get a better response. I'll ask the mods to move it.
-tg
Re: Pass Exception Message to label on another page
The try catch is inside a public function so will this method work?
Re: Pass Exception Message to label on another page
Moved to the ASP.Net forum.
Re: Pass Exception Message to label on another page
Re: Pass Exception Message to label on another page
Hey,
Depending on exactly what you are trying to do, and for what reason, you might want to look into something like ELMAH:
https://code.google.com/p/elmah/
Which does the job of collating all your error messages, and logging them for you.
Gary
Re: Pass Exception Message to label on another page
Every unhandled exception will pass and logged through global.asax so you don't really need an extra plug in but if you want more automated control then i guess you can try it (haven't used it).
Re: Pass Exception Message to label on another page
For what it's worth, ELMAH is very good at what it does :)
Gary