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.