Containg Types Or Base Types

Discussion in 'ASP .Net' started by rn5a@rediffmail.com, Nov 22, 2006.

  1. Guest

    A user control file named Address.ascx has 4 TextBoxes. The logic of
    this user control is encapsulated in a code-behind file named
    Address.ascx.vb. The code-behind also defines an Event named
    "TextChangedEvent" which handles the TextChanged event of the 4
    TextBoxes.

    Namespace Address
    Public Class AddressCB : Inherits UserControl
    Public txt1 As TextBox
    Public txt2 As TextBox
    Public txt3 As TextBox
    Public txt4 As TextBox

    ..........
    ..........

    Public Event TextChangedEvent(ByVal obj As Object, ByVal ea As
    EventArgs)

    Protected Sub txt1Changed(ByVal obj As Object, ByVal ea As
    EventArgs) Handles txt1.TextChanged
    RaiseEvent TextChangedEvent(obj, ea)
    End Sub

    Protected Sub txt2Changed(ByVal obj As Object, ByVal ea As
    EventArgs) Handles txt2.TextChanged
    RaiseEvent TextChangedEvent(obj, ea)
    End Sub

    Protected Sub txt3Changed(ByVal obj As Object, ByVal ea As
    EventArgs) Handles txt3.TextChanged
    RaiseEvent TextChangedEvent(obj, ea)
    End Sub

    Protected Sub txt4Changed(ByVal obj As Object, ByVal ea As
    EventArgs) Handles txt4.TextChanged
    RaiseEvent TextChangedEvent(obj, ea)
    End Sub
    End Class
    End Namespace

    When the user control is executed, ASP.NET generates the following
    error:

    Handles clause requires a WithEvents variable defined in the containing
    type or one of its base types.

    pointing to the

    Protected Sub txt1Changed(........)

    line. I resolved the problem by declaring the 4 TextBoxes shown above
    using WithEvents

    Public WithEvents txt1 As TextBox
    Public WithEvents txt2 As TextBox
    Public WithEvents txt3 As TextBox
    Public WithEvents txt4 As TextBox

    Though my problem has been resolved, I couldn't exactly understand what
    the error message means especially the part "defined in the containing
    type or one of its base types". Can someone please explain me what does
    "defined in the containing type or one of its base types" mean? Which
    is the "containing type" here? Also does "base types" refer to the user
    control?
     
    , Nov 22, 2006
    #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.

Share This Page