Solved

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

Posted on 2006-07-19
4
259 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Editing XSL files, 2 43
Binding a check box in an Asp.net DataGrid 4 40
getting id from database 5 37
Disable and re-enable a dynamic System.Timers.Timer 6 42
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…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now