I want to get all the listitems that exist in a listbox using jquery, it does not matter if selected or not.
Here is my client side script:
<asp:ListBox ID="lstSelected" runat="server" SelectionMode="Multiple" Rows="10">
<asp:ListItem Value="Employee_OID">EID</asp:ListItem>
<asp:ListItem Value="EmpID">Emp ID</asp:ListItem>
<asp:ListItem Value="Employee_Name">Name</asp:ListItem>
</asp:ListBox>
By adding a static ID (ClientIDMode=”Static”) generation to the ListBox, you could use the ID property value in jQuery directly (skipping ClientID usage):
jQuery to get all options:
jQuery to get all selected options:
See more info here on the ClientIDMode:
http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode.aspx