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

前端 未结 8 1998
旧巷少年郎
旧巷少年郎 2021-01-04 03:15

I get the error

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

in the following co

相关标签:
8条回答
  • 2021-01-04 03:19

    I've gotten this error when for some I've renamed a field. For some reason sometimes the designer messes up and doesn't rename it in the form.aspx.designer.vb file, if you look in there and fix the name it can fix this issue if that has happened to you.

    So double check that the field name is the same in your even handler, the aspx file and the designer.aspx files.

    0 讨论(0)
  • 2021-01-04 03:20

    I had this error on a handler function for an ASP button on vb.net. Solved by adding

    runat="server"
    

    to the enclosing form tag

    <form name="formUpdate" method="post" id="frmUpdate" runat="server">
         <asp:Button ID="btnUpdate" runat="server" Text="Update" />
     </form>
    
    0 讨论(0)
  • 2021-01-04 03:26

    I had encountered this issue when upgrading a legacy page. The problem is in the Inherits attribute @Page directive has the wrong namespace.

    1. Correct the namespace for Inherits attribute
    2. Remove the namespace in the designer file or match with it in the designer code
    0 讨论(0)
  • 2021-01-04 03:27

    I had this happen on the OnClick event for a button. I originally the button inside a panel inside of an ItemTemplate for a gridview column. I only needed the panel to popup on some other buttons OnClick event so I didn't really need it repeated through out the grid. It was hidden anyhow. I moved the panel outside the gridview all together and the error went away.

    0 讨论(0)
  • 2021-01-04 03:29

    I encountered this error in a solution while testing something. It is related to Designer.vb related to the form. Make sure that it was updated.

    0 讨论(0)
  • 2021-01-04 03:30

    When converting a legacy Web Sites Project to a Web Application Project type, when following these directions, after converting the application, it created a bunch of .aspx.designer.vb files for me but didn't include them in the project. So I clicked on the project root in solution explorer, pressed the * key to expand everything, then multiselected all of the designer.vb files and right-clicked then said 'include in project'. Then it was able to see the types and the compiler lived happily ever after.

    THE END

    0 讨论(0)
提交回复
热议问题