listbox select event

listbox select event
To enable the listbox select event, you need to set listbox AutoPostBack proerty to true.

<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" AutoPostBack="True" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">

<asp:ListItem>Moto</asp:ListItem>

<asp:ListItem>Samsung</asp:ListItem>

<asp:ListItem>Micro</asp:ListItem>

<asp:ListItem>Sony</asp:ListItem>

<asp:ListItem>AIWA</asp:ListItem>

<asp:ListItem>APPLE</asp:ListItem>

<asp:ListItem>Acer</asp:ListItem>

</asp:ListBox>

<br />


C# code behind

protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)

{

Response.Write(ListBox1.SelectedValue);

}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5