if (list.options[i].selected) {
listval=list.options[i].value +"," + listval
}
if muliple items are slected then there is no issue but if only one item is selected i get i double times
Where is the dropdown here?. Please post proper code using proper formatting and make use of Code button to add code as said earlier so that we cna understand and read it
<asp:UpdatePanel ID="UpdatePanel2" runat="server" > <ContentTemplate> <div runat="server" style="position: absolute; z-index: 122; " id="divcity"> <asp:ListBox ID="drpcity" runat="server" Height="252px" SelectionMode="Multiple" Width="141px"></asp:ListBox></div> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnpb" /> </Triggers> </asp:UpdatePanel> var list = document.getElementById('drpcity'); debugger; for (var i = 0; i <=list.options.length-1; ++i) { if (list.options[i].selected) { var lstval ; lstval = list.options[i].value +","+ lstval ; } }
Change line 27 to
var lstval = "";
ok
after selcting the item i do post back
if agian the listbox is made visible how do i get the initally slected items to remain selected on client side
culd do it on serverside
The values that you set client side you can fetch server side. using
string values = Request.Form[drpcity.UniqueID]
This will give you comma separated values Eg 1.2.5.
You will have to do this way as you are settings values client side
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.