Solved

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

Posted on 2006-07-19
4
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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