Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

postback does not preserve state of listbox that has been changed using javascript

I have an aspx page with few web server ListBox, one of the listBox is empty. I have client side java script that populate the empty ListBox on a button click. Everything works fine.

Now when I do a postback via a LinkButton, I lose the data populated via the javascript. Anythoughts why this is happening and what should I do?
0
pharosinnyc
Asked:
pharosinnyc
  • 2
1 Solution
 
TimCotteeHead of Software ServicesCommented:
Hi pharosinnyc,

Because the data that you populated client-side is not stored in the viewstate and therefore not available to the server-side code.

There is nothing that you can really do about this except use a work-around such as storing the populated data in a hidden form field with runat="server" perhaps as | delimited string and then parse this at the server side when you post back to deal with it accordingly.

Tim Cottee
0
 
pharosinnycAuthor Commented:
oh.. I suspected this.. exactly what I didnt want to hear.lol

Does this mean to take full advantage of postback we shouldnt use client side javascript? I am just starting to use .net

0
 
Bob LearnedCommented:
Yeah, or if you are working client-side, then stay client-side, since you can't mix the two without a bridge in between (hidden form field).

Bob
0
 
pharosinnycAuthor Commented:
k. Thanks Bob/Tim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now