asp.net 2.0 script callbacks

K

kelly

Hi

I have an app where I have 2 dropdown lists (state and city) and a Save
button. When a user selects a value from the state dropdown list, I
use script callback to populate the data for the city dropdown list.
By using script callback, I'm able to execute server side functions
without a postback.

Now here is my problem...let's say I selected Illinois and then Chicago
on the dropdown lists. After I click on Save, the city dropdown list
no longer shows Chicago as the selected value, but shows the first item
in the city dropdown list instead. It seems as if the viewstate is not
being saved/updated or the control is not refreshed correctly?

Is anyone else having this problem using script callbacks? It seems as
if I need to also change the viewstate field on the client side using
javascript?


Kelly
 
X

xkeops

You should post the code for more information but are you sure your
dropdown lists are runat=server ?

XK
 
K

kelly

The dropdownlists are part of a user control and I save the selected
values using the SaveControlState. But since I'm using script
callbacks to populate the city dropdownlist and no postback occurs, I
believe SaveControlState is not saving correctly.

Kelly
 
G

Guest

Kelly,
That's correct, the simple script callback doesn't preserve the stateful
page class on the server side. You could do this with something like
Anthem.Net because it handles callbacks by actually instantiating the Page
class and preserving the page state. Find it on Sourceforge.net. Or, if you
are more adventurous, ATLAS.
Peter
 
K

kelly

Peter

Thanks for the reply...but is there a way for me to get around this in
asp.net 2.0? Since they introduced this feature, I'm sure many others
have had the same problem.


Kelly
 
G

Guest

if you are attempting to store values in the page where there is not a
postback,
you can store them in hidden fields on the page (for example), and when your
script callback is called, part of it's work would be to go get those values
and update whatever control needs to be "refreshed" via client-side
Javascript and the HTML DOM.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
K

kelly

Do you know if it's possible to modify/update the ControlState from the
client side using javascript?

I am able to modify the dropdownlist values on the client side using
javascript but do not know how to modify/update the ControlState also
on the client side. The control I'm using is a complex control and it
calls LoadControlState when the Save button is clicked on to get the
values of the controls on the page.

Kelly
 
G

Guest

Isn't ControlState a server-side property? The only thing you have on the
client side is a bunch of HTML and possibly some javacript sitting in the
browser, right?
Take a look at Anthem.Net. It will help you to understand all this better,
and save you a lot of time.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top