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. Advertisements

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. Daniel

    event from itemtemplate not raised

    Daniel, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,062
    Scott Allen
    Oct 22, 2004
  2. Brad
    Replies:
    1
    Views:
    916
    Steven Cheng[MSFT]
    Mar 31, 2005
  3. Karch
    Replies:
    2
    Views:
    398
    sloan
    Mar 2, 2007
  4. JC

    Dynamically added usercontrol raised events

    JC, Oct 12, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    244
  5. Event not firing in usercontrol inside usercontrol

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

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

    , Dec 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    281
  8. NH
    Replies:
    2
    Views:
    738
    Andrew L. Van Slaars
    Dec 17, 2004
Loading...