UserControl Error event is not raised

Discussion in 'ASP .Net' started by Brad, Mar 8, 2005.

  1. Brad

    Brad Guest

    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
    Brad, Mar 8, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad
    Replies:
    1
    Views:
    705
    Steven Cheng[MSFT]
    Mar 31, 2005
  2. Event not firing in usercontrol inside usercontrol

    , Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    171
  3. Event not firing in usercontrol inside usercontrol

    , Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    180
    vatech1993
    Dec 11, 2004
  4. Event not firing in usercontrol inside usercontrol

    , Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    147
  5. NH
    Replies:
    2
    Views:
    516
    Andrew L. Van Slaars
    Dec 17, 2004
Loading...

Share This Page