Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-07-15
4
Medium Priority
?
621 Views
Last Modified: 2012-05-07
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

0
Comment
Question by:Robert Treadwell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24861820
Protected WithEvents InsertButton As Button is missing in the designer file. Did you delete and recreate the control?
0
 

Author Comment

by:Robert Treadwell
ID: 24863048
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

0
 
LVL 15

Accepted Solution

by:
mohan_sekar earned 750 total points
ID: 24863321
Did you set a breakpoint and see whether the the Sub is getting called?
0
 
LVL 9

Expert Comment

by:Seven price
ID: 24948204
what was the with events variable
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question