AJAX TabContainer - losing ListBox data on postback

M

Mel

On a tab I have one DropDownList which requires a postback and two
ListBoxes which do not require any postback because I just have some
javascript, defined in the aspx file, to copy items from one listbox
to the other. All 3 of these controls exist in a table which is
inside an UpdatePanel. When the drop down list value changes and the
postback occurs the data that I had in my listbox control disappears.
How do I fix this?

(using: asp.net 2.0, vb.net, visual studio 2005, winxp pro sp2)
 
B

bruce barker

the browser only sends back the selected value to the server. if
javascript adds a new value, when the postback is processed on the
server, the server side DropDownList has no matching item to select.

in oninit you need to add code on the server side that adds the new
value to the DropDownList. you could look in the form collection for the
value.

-- bruce (sqlwork.com)
 
M

Mel

the browser only sends back the selected value to the server. if
javascript adds a new value, when the postback is processed on the
server, the server side DropDownList has no matching item to select.

in oninit you need to add code on the server side that adds the new
value to the DropDownList. you could look in the form collection for the
value.

-- bruce (sqlwork.com)

I don't understand what you mean...
 
M

Mel

I don't understand what you mean...

I figured it out. When I copy, move position, or delete an item from
the listbox I call a Get_Item_List function in Javascript to store all
of the items to a hidden field. Then on page_load of the form if the
hidden field has a value I update the list box with the items I have
stored in the hidden field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top