listBox ViewState lost

  • Thread starter Thread starter Frank
  • Start date Start date
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
 
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
 
Back
Top