Hi Alan,
I have made a declaration at the top of the page to use the namespace, in
regards to where I put the declaration that you posted I have tried to place
it all over the page but I still receive an error, could you help me out
with the syntax?
Seam
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<% @Import Namespace="System.Web.UI.WebControls.DropDownList" %>
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
' BindData()
End Sub
Private Sub lstRegion_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lstRegion.SelectedIndexChanged
Protected WithEvents DropDownList1 As
System.Web.UI.WebControls.DropDownList
response.write ("test")
End Sub
</script>
<html>
<body>
<form runat=server>
<ASP:DropDownList id=lstRegion AutoPostBack="true" name=lstRegion
maxlength= "40" SelectedIndexChanged=lstRegion_SelectedIndexChange d
runat=server>
<asp:ListItem Value="1">New South Wales</asp:ListItem>
<asp:ListItem Value="2">Victoria</asp:ListItem>
<asp:ListItem Value="3">Tasmania</asp:ListItem>
<asp:ListItem Value="4">South Australia</asp:ListItem>
<asp:ListItem Value="5">Western Australia</asp:ListItem>
<asp:ListItem Value="6">Northern Territory</asp:ListItem>
<asp:ListItem Value="7">Queensland</asp:ListItem>
</ASP:DropDownList>
</form>
</html>
</body>
"Alan Ferrandiz Langley" <af********@online.labroe.com> wrote in message
news:uZ*************@TK2MSFTNGP11.phx.gbl...
When you try to submit the ASP.NET Web Form with a dropdownlist you do it
by creating an event handler for the SelectedIndexChanged event using the
AutoPostback property. Well, for your control to expose events it has to
be declared using the WithEvents clause otherwise you won't be able to handle
any event with your code. In short, your control declaration has to look
like this:
Protected WithEvents DropDownList1 As
System.Web.UI.WebControls.DropDownList
Alan Ferrandiz
MCT,MCDBA,MCSD
MSF Practitioner
"Sean" <se**********@shopsmart.com.au> escribió en el mensaje
news:uu**************@TK2MSFTNGP12.phx.gbl... HI There,
I am trying to submit a form when a selection is made from a dropdown
list, I keep getting the error "Handles clause requires With Events Variable".
Could someone help me with the syntax?
Sean - Thanks in advance
<script language="vb" runat="server">
Private Sub lstRegion_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles lstRegion.SelectedIndexChanged
response.write ("test")
End Sub
</script>
<html>
<body>
<form runat=server>
<ASP:DropDownList id=lstRegion AutoPostBack="true" name=lstRegion
maxlength= "40" SelectedIndexChanged=lstRegion_SelectedIndexChange d
runat=server>
<asp:ListItem Value="1">New South Wales</asp:ListItem>
<asp:ListItem Value="2">Victoria</asp:ListItem>
<asp:ListItem Value="3">Tasmania</asp:ListItem>
<asp:ListItem Value="4">South Australia</asp:ListItem>
<asp:ListItem Value="5">Western Australia</asp:ListItem>
<asp:ListItem Value="6">Northern Territory</asp:ListItem>
<asp:ListItem Value="7">Queensland</asp:ListItem>
</ASP:DropDownList>
</form>
</html>
</body>