UserControl Error event is not raised

B

Brad

I added an Error event to a web usercontrol (ascx), but when an error is
raised in the control it does not get called...only the Application_Error
even in the global.asax gets called. The same thing in an aspx works
correctly. Does the Error event not really work with a user control or is
there something I am misunderstanding?

Thanks

Brad

Code Example:
==============================
Public Class WebUserControl1
Inherits System.Web.UI.UserControl

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'bad code which causes an error
Dim x As DataTable
Dim y As DataRow = x.Rows(0)

End Sub

Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Error
'do something here
'add a debug breakpoint to test error raised.
End Sub
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top