listBox ViewState lost

F

Frank

Hi all,

I have a listBox which is filled with data if not isPostBack. Then on client
side, one more item is added to the listBox( using New Option in
JavaScript). Then on a server button click event, I want to retrieve the
newly added item. But it's not there. EnableViewState has been set to true.
I know if I add listItem on the server, it will keep the viewState. But I
want to do it on the client side.

Did I do something wrong?

Thanks a lot.
Frank
 
N

Natty Gur

Hi,

In postback (as any request to the server) only the selected value of
list\combo box sends to the server. asp.net uses hidden field called
__viewstate. This field is create on the server and holds the last state
of server controls. __viewstate also send to the server as part of the
form fields. When the asp.net get request he can build the controls last
sate from the __viewstate data. That mean that every data that you will
add on the client side wont be send in any way to the server nor it will
add to static field (__viewstate) that made on the server side.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top