Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have 2 asp:listboxes and 2 buttons in my page. one button is a normal HTML button and the other is an asp:button.

I've a list of values in the first listbox. on my html button click, the values are being copied/moved to the second list box using a function written in jQuery. But when i click on my asp:button which check the values inside second listbox, it shows the count of items in the listbox as 0.

Is there any way i can get the values of second listbox on the asp:button click?

Thanks,
Daion
Posted

1 solution

Dropdown, list box, labels etc. are serialized and state is stored in viewstate. So when you do the postback the controls are recreated and the values are loaded from viewstate. Hence you cannot see the items added through JavaScript in second listbox.

The only way to get it working is have a hidden field on the page. Add the selected items from listbox1 as comma separated list in the hidden field in the same function where you are adding it to second listbox and then access the values from this hidden field at server side on postback.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900