2
Answers

Problem with a ListBox populated from javascript

Hello, First of all, excuse-me for my poor English... I have a big problem with my ListBox which is populated from javascript. When I do a PostBack in order to update my database the ListBox values are lost. I tried to do something with ViewState = true for my page and listboxes but it doesn't seem to work. Have you got any ideas how to post back the values of my listbox to the server? Thanks in advance. durtal
Answers (2)
0
thomas.jaskula
NA 5 0 20y
Hello Stefan, Thanks for fast response. It works like a charm ;)
0
S_Kiryazov
NA 145 0 20y
First, your English if fine. I didn't notice a single mistake I had the same problem and I din't come up with quite a civilized solution but it works. In the javascript method that submits the data I loop through the items in the list box and form a string containing a coma separated list (you'd better not allow comas in the items values (-; ), pass it to the server through a hidden input and then parse it on the server. The code is something like: javscript: function showCity(){ var result = new String(); var resultText = new String(); //alert("we're in"); for(i=0;i