Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2004, 12:27 AM
Authorized User
 
Join Date: Jul 2004
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)
            conCustomers.Open()
            'cmdCustomers.Connection = conCustomers
            lstCustomer.DataSource = cmdCustomers.ExecuteReader()
            lstCustomer.DataTextField = "contacttitle"
            lstCustomer.DataBind()
            conCustomers.Close()

        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

</script>

<body>

    <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>

    </form>
</body>

PLease help! Am very new to asp.net.


 
Old July 16th, 2004, 12:41 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

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







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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.