You will need to handle the Error event.
Try adding Handles MyBase.Error to yous Page_Error sub.
Sub Page_Error(ByVal sender As Object, ByVal e As EventArgs) Handles
MyBase.Error.
This Page.Error event is triggered when an unhandled exception occurs
anywhere during page processing. The Application.Error will fire when
outside of the scope of a page.
Try this out and let us know how it resolved out.
Here is the stub I used to test it out.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Throw New Exception("Exception Thrown")
End Sub
Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Error
Dim exception As Exception
exception = Server.GetLastError()
Response.Write(exception.Message)
Server.ClearError()
End Sub
bill
[quoted text, click to view] "Alex Nitulescu" <REMOVETHIScuca_macaii2000@yahoo.com> wrote in message
news:O1zyD%23kDFHA.2620@tk2msftngp13.phx.gbl...
> Hi.
>
> I read about Page_Error and Application_Error. However, I provoke an error
> in a page but still Page_Error won't run. This is all the code I have left
> in my page:
>
> --------------------------------------------------------------------------
-------
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> Dim txtTextBox As TextBox
> txtTextBox.Text = "A"
> End Sub
>
> Sub Page_Error(ByVal sender As Object, ByVal e As EventArgs)
> Response.Write("Error: ")
> Response.Write("<p></p>")
> Response.Write(Server.GetLastError.Message)
> Server.ClearError()
> End Sub
> --------------------------------------------------------------------------
-------
>
> I see "Object reference not set to an instance of an object" in the
default
> ASP.NET error page....
> I have played with Debug=true/false, trace=True/False, <customErrors
> mode="On/Off/RemoteOnly" />, etc, but to no avail.
>
> Please, what am I missing here ?
>
> Thank you, Alex.
>
>