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

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

Tags:

Vb.Net

Asp.Net