Consider the following: A text value added to a textbox on the client is added to viewstate on postback (thus the value is still present in the textbox when the page has reloaded).
How come when I move a value from listbox1 to listbox2 via jquery the items in listbox2 are not added to viewstate. (note: the items are selected before POST and the values in listbox2 are available on the server on postback via request.form.getvalues(“listbox2”).getvalue(index).tostring())
I’m not looking for a work around, I’ve got that. I’m want to know “why” the listbox2 values are not added. Is there some event being fired for the textbox but not the listbox? Just trying to better understand what’s going on. Thanks!
This statement is incorrect. The value of a
TextBoxserver control is preserved across postbacks because the browser sends it in the post data, and on postback theTextBoxcopies the value from the post data to itsTextproperty. View state is not involved, as you can verify by settingEnableViewState="False". (I’m assuming here that theTextBoxis visible and enabled; otherwise, the browser doesn’t sent its value in the post data, and view state is required to preserve the value.)For a multi-selection
ListBoxserver control, the browser sends the value of each selected item in the post data. On postback, theListBoxlooks at each value in the post data, searches for the corresponding item in itsItemscollection, and sets that item’sSelectedproperty toTrue. It doesn’t add unrecognized values to theItemscollection; instead, if event validation is enabled, it throws an “Invalid postback or callback argument” exception. Again, view state is not involved.