开发者

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

开发者 https://www.devze.com 2023-04-11 08:56 出处:网络
I get the error Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

I get the error

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

in the following code..

Public Sub selCurrentManuf_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles selCurrentManuf.SelectedIndexChanged

    End Sub

The drop list to go with it is the following...

<asp:DropDownList  
   OnSelectedIndexChanged="selCurrentManuf_SelectedIndexChanged" 
   selectedvalue='<%#Container.DataItem("c1_manufidcurrent")%>' 
    ID="selCurrentManuf" 
    Runat="Server"开发者_JS百科 
    DataTextField="c4_Desc" 
    DataValueField="c4_manufid"
    DataSource="<%# GetCurrentManuf() %>" 
    autopostback="true" 
 ></asp:DropDownList>


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.


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


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.


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


I had this happen when I created a command button. When I let VB.net create the event I was immediately greeted with that error. What I did to fix it was deleted the object in the designer (a command button in my case), the code tied to it, saving my .sln & recreating the object. Problem solved.


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>


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.


Error may like this in winform vb.net

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

solution:

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

Change this :

  Public button3 As Button

TO:

  Public WithEvents button3 As Button


Actually there is some fault in the designer. Closing and Re-Opening the solution fixes it


I got this error randomly 268 times in a solution that I hadn't changed. I closed and reopened the file and it seemed to fix it...

0

精彩评论

暂无评论...
验证码 换一张
取 消