[.Net 2.0 / AJAX] Drop Down Lists Populating/Repopulating

R

Rob Meade

Hi all,

Looking for a bit of help if possible.

For about 2 weeks now I've been investigating the best way to populate
related drop down menus, and have their values pre-populated again if the
user clicks back with their selected options still selected - and I'm
getting to the point where I might just popup a big window, perhaps with
some flash in it and say "dont be lazy, select em again you great big freak
of nature" because I am that thoroughly fed up!

I've started using Ajax, dont pretend to be an expert, but from an example
online I've managed to get my three drop down's populate upon the selected
item being changed without the page refreshing - marvellous - so imagine my
delight when I added a button to my test page in order to create a postback
to find that when I then hit back in the browser its just as if the page has
been loaded for the first time again....

*sigh*

Does anyone have any experience with doing this? I'm not looking for a
component or pre-written drop-in code - just some help with what I have
would ideal...

I'm kinda concerned that with the Ajax approach I've adopted, the form
elements might be updated with content for the user to see, but there wont
actually be anything behind it, ie, on the page, thus when its submitted
there's no viewstate (stop me if I'm sound like a complete moron at any
point please), thus I cant rely on that to then update the boxes when the
user clicks back.

I would prefer to avoid the use of a session variable to store any
selections - feels a bit dirty...

Any help would be really appreciated, I have to places in my application
where this "functionality" is required, one at the beginning, and one a page
on from the beginning, needless to say its causing me a huge time-slip on
this project....(I'd spit all the options out as hyperlinks if there were
not so many of em!)

Regards

Rob
 
B

bruce barker

there are a couple approaches

1) save the list changes in session
2) save the list changes in a hidden field that client script updates
3) in oninint look in the form collection for the postback values and
inital the lists.
4) create a custom dropdown that supports a postback value not in the list.

-- bruce (sqlwork.com)
 
D

darrel

I've started using Ajax, dont pretend to be an expert, but from an example
online I've managed to get my three drop down's populate upon the selected
item being changed without the page refreshing - marvellous - so imagine
my delight when I added a button to my test page in order to create a
postback to find that when I then hit back in the browser its just as if
the page has been loaded for the first time again....

I think that's normal. One of the drawbacks of AJAX is that it can break the
back/forward behavior in a browser (since there really aren't any new pages
to go back to).

Why are people using the back button in this case? Can this be resolved via
other UI elements?

-Darrel
 
R

Rob Meade

...
I think that's normal. One of the drawbacks of AJAX is that it can break
the back/forward behavior in a browser (since there really aren't any new
pages to go back to).

Yeah, this I've noticed, each time my code runs it seems to behave like a
postback - thus making the Page.IsPostBack a little redundant :eek:/
Why are people using the back button in this case? Can this be resolved
via other UI elements?

It wouldn't be through choice, it's those annoying users we all try so hard
to please :eek:)

The application will be used by approximately 10,000 users, I have to assume
that at least one of them is likely to click back or hit those extra mouse
buttons, just try to cover all eventualities, I must admit, I didn't expect
something like this to take so long though! With all these clever widgets
and things around the net these days its a shame some of the "simpler" tasks
still seem to be a nightmare!

Regards

Rob
 
R

Rob Meade

...
3) in oninint look in the form collection for the postback values and
inital the lists.

So effectively repopulating them and specifying the selected item yes?
4) create a custom dropdown that supports a postback value not in the
list.

I have a "progess" meeting this afternoon and doubt I'll get a lot more time
on this to be honest, although that sounds like a better solution in the
long term.

Regards

Rob
 
D

darrel

The application will be used by approximately 10,000 users, I have to
assume
that at least one of them is likely to click back or hit those extra mouse
buttons, just try to cover all eventualities, I must admit, I didn't
expect something like this to take so long though! With all these clever
widgets and things around the net these days its a shame some of the
"simpler" tasks still seem to be a nightmare!

One option that might work is anytime you do a UI update via AJAX on this
page (change the value of one of the DDLs, set a session variable to
remember the state of the pulldown menus.

-Darrel
 
R

Rob Meade

...
One option that might work is anytime you do a UI update via AJAX on this
page (change the value of one of the DDLs, set a session variable to
remember the state of the pulldown menus.

Having put the original problem to one side momentarily, I've put my code
for the Ajax stuff into my "proper" page as opposed to the test page.

The test page just had 3 drop downs, the ajax stuff reloaded each child drop
down each time the parent drop down was changed, other than that the page
had no other controls, did nothing else.

Now I have the code on my proper page - but I think I'm in trouble now!

This is a significantly more complex page, there are effectively 3 pages in
one using panels, its for a registration process, so in the page load there
are a lot of if...then's checking to see at which stage of the process you
are, ie, step 1 not posted, step 1 posted etc etc...

I think this has just killed the Ajax functionality, as all it does now is a
form post - any thoughts?

I'm becoming more turned off by Ajax as I use it - I read someone else
querying why the 1.0 release had changed something, they made some comments
to why it was now doing a full postback - not sure if this is my problem or
not - but I had noticed that the Page.IsPostBack was always true whenever my
Ajax stuff fired - thought this was a bit odd...

Rob
 

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,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top