Dropdownlist event not getting fired...

finnybimE

New Member
The selectedindexchanged event of my DropDownList box is not getting trigerred. Please advice. Here is the ASP and C# code.<BR><BR>ASPX:<BR>-----<BR><form id="WebForm2" method="post" runat="server"><BR><asp:DropDownList id="DropDownList1" runat="server"><BR> <asp:ListItem Selected="True" Value=http://aspmessageboard.com/archive/index.php/"1">One</asp:ListItem><BR> <asp:ListItem Value="2">Two</asp:ListItem><BR></asp:DropDownList><BR></form><BR><BR>Code Behind:<BR>------------<BR>private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)<BR>{<BR> Response.Write ("????????");<BR>}<BR>Specifying the event handler explicitly inside the pageload method is also not helping in firing the event :<BR><BR>private void Page_Load(object sender, System.EventArgs e)<BR>{<BR>DropDownList1.SelectedIndexChanged += new System.EventHandler (DropDownList1_SelectedIndexChanged);<BR>}You need to specify what function it should call on change so you need the start tag to look something like<BR><asp:listbox runat="server" id="myList" OnSelectedIndexChanged="functionToCall"><BR><BR>If you want it to call the function as soon as the item is changed you also need <BR>autopostback=true in there<BR>After putting autopostback=true, it works.<BR>Thanks a lot !!!
 
Back
Top