Solved

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

Posted on 2006-07-19
4
261 Views
Last Modified: 2012-06-27
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
Comment
Question by:pharosinnyc
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 17138958
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
 

Author Comment

by:pharosinnyc
ID: 17139082
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17139085
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
 

Author Comment

by:pharosinnyc
ID: 17139112
k. Thanks Bob/Tim
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question