"bogdan" <bo****@nospam.comwrote in message
news:em**************@TK2MSFTNGP03.phx.gbl...
Thanks for the reply. Since I'm rather new to asp.net I think I
miscalculated what I could do on the client side. I have the code working
moving items between listboxes but have no clue how to pass items of one
of the listboxes back to the server. I could put a 'Save' button that
would post back to the server but I don't know how to pass the new set of
items in the listbox. The old ones are in the viewstate. Is there a way
to do that? I might try to select all items on the client side before
posting back but I'm afraid that this might not work because of
discrepancies between old items and selected ones (e.g. selected items
were not present in the list when it was sent to the client).
Client-side changes to the element collection of listboxes are not persisted
across a postback.
Therefore, the "usual" workaround for this is to populate a hidden text box
with as much information as the server-side code needs for its purposes.
E.g. if the "first" listbox contains the following elements:
First
Second
Third
Fourth
Fifth
and it's possible client-side to move any or all of these elements into the
"second" listbox, just before the postback happens (e.g. in the
OnClientClick of a button control) inspect the contents of the "second"
listbox. Let's say that the second listbox now contains the first, third and
fifth elements from the first listbox. Therefore, place the following value
in a hidden text box: "1¬3¬5". This will be posted back to the server along
with the rest of the web form where it will be a simple matter to parse out
the value and identify which of the elements had been moved from the first
listbox to the second.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net