Link to home
Start Free TrialLog in
Avatar of Robert Treadwell
Robert TreadwellFlag for United States of America

asked on

VB Code is giving error Handles clause requires a WithEvents variable.

I have a form that is giving me the following error "Handles clause requires a WithEvents variable" how do I fix my problem?
Button on *.aspx form
<asp:Button ID="InsertButton" runat="server" CausesValidation="True"
                         CommandName="Insert" Text="Submit"/>   
 
Code in *.aspx.vb
Protected Sub InsertButton_Command(ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.CommandEventArgs) Handles InsertButton.Command
        Server.Transfer("~/ContentPages/Testimonials.aspx", False)
    End Sub

Open in new window

Avatar of mohan_sekar
mohan_sekar
Flag of United States of America image

Protected WithEvents InsertButton As Button is missing in the designer file. Did you delete and recreate the control?
Avatar of Robert Treadwell

ASKER

I added the withEvents sub, now I not getting the error but my page is not being transfered to the next page.  See the code below to see if that may help you help me.

Partial Class ContentPages_Testimonial
    Inherits System.Web.UI.Page
 
    Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles InsertButton.Click
        Server.Transfer("~/ContentPages/Testimonials.aspx", False)
    End Sub
 
    Protected WithEvents InsertButton As Button
 
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mohan_sekar
mohan_sekar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what was the with events variable