Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Feb 2014
    Posts
    188
    Thanks
    41
    Thanked 0 Times in 0 Posts

    Handles and WithEvents variable question

    Hello

    I am getting an error message on this line of script (attached) in my aspx.vb file:

    Code:
     Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton_Click.Click.
    I know the 'SubmitButton_Click' part is incorrect or insufficient and the error message I get in my browser is:

    Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
    This relates to this line in my normal aspx file:

    Code:
    <asp:Button ID="SubmitButton" runat="server" OnClick="SubmitButton_Click" Text="Register" CssClass="btn btn-default" />
    I am trying to understand the article here: WithEvents and the Handles Clause

    but it's not making too much sense!

    Any help would be appreciated.

    Thanks

    Blue
    Attached Thumbnails Attached Thumbnails Handles and WithEvents variable question-handles.jpg  

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,823
    Thanks
    42
    Thanked 199 Times in 198 Posts
    because SubmitButton_Click is the name of the event that gets raised, not the object (button). Should be
    Code:
     Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click.
    *remove in red*
    Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton_Click.Click.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •