I'd like to use the Error event of an ASPX page to catch any unhandled exceptions that occur in that page and set the text of a label control to display the error to the user (I realize this is likely not a recommended best practice, this is a quick and dirty).
So, in the error event, I would have something like:
Me.lblError.Text = Server.GetLastError.Message
However, when I run this and the error occurs, I can see this line is executing by setting a breakpoint, but the screen always ends up blank. I have tried with and without a Server.ClearError after setting the text, but the result is the same.
Shouldn't this be possible??
Update
See correct answer below, as well as this article:
http://msdn.microsoft.com/en-us/library/ed577840.aspx