Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 15th, 2004, 12:27 AM
Authorized User
Join Date: Jul 2004
Location: , , .
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default BC30506: Handles clause requires a WithEvents vari

I get an error on execution of a aspx file. The error is:

Compiler Error Message: BC30506: Handles clause requires a WithEvents variable.

Source Error:
Line 26: End Sub
Line 27:
Line 28: Public Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Line 29: Dim valCustomer As String
Line 30: valCustomer = lstCustomer.SelectedItem.Text

The code of aspx is as follows:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script language="vb" runat="server">

    Dim conCustomers As SqlConnection
    Dim daCustomers As SqlDataAdapter
    Dim dsCustomers As DataSet
    Dim cmdCustomers As SqlCommand

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If Not IsPostBack Then
            conCustomers = New SqlConnection("server=localhost;uid=sa;pwd=;databa se=northwind")
            cmdCustomers = New SqlCommand("select contacttitle from customers", conCustomers)
            'cmdCustomers.Connection = conCustomers
            lstCustomer.DataSource = cmdCustomers.ExecuteReader()
            lstCustomer.DataTextField = "contacttitle"

        End If

    End Sub

   Public Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        Dim valCustomer As String
        valCustomer = lstCustomer.SelectedItem.Text
        Response.Redirect("ReportDatasetDyn.aspx?cust=" & valCustomer)
    End Sub



    <form id="Form1" method="post" runat="server">

    <asp:ListBox id="lstCustomer" style="Z-INDEX: 101; LEFT: 72px; POSITION: absolute; TOP: 72px" runat="server" Height="296px" Width="152px"></asp:ListBox>
       <asp:Button id="btnDisplay" runat="server" Text="DISPLAY PAGE" ></asp:Button>


PLease help! Am very new to asp.net.

Reply With Quote
  #2 (permalink)  
Old July 16th, 2004, 12:41 AM
Friend of Wrox
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi

You are missing the Withevents variable declaration.
The syntax is
Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Friend WithEvents kscase Visual Basic 2005 Basics 1 May 3rd, 2007 03:16 PM
Handles clause requires a WithEvents on BUTTON?!?! Ron Howerton ASP.NET 2.0 Basics 1 April 24th, 2007 03:24 PM
Cannot display/return SQL Query Output from a Vari sjm SQL Server DTS 1 September 9th, 2005 11:40 AM
Abt Advantages & disadvantages of Application Vari anandham Classic ASP Databases 1 May 13th, 2005 06:23 PM
Need help w/ "WITHEVENTS" & the Outlook Obj ArtDecade VB How-To 1 October 27th, 2004 03:50 AM

All times are GMT -4. The time now is 08:11 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.