Robert Treadwell
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
Protected WithEvents InsertButton As Button is missing in the designer file. Did you delete and recreate the control?
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what was the with events variable