467,144 Members | 1,412 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,144 developers. It's quick & easy.

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

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
Jan 30 '07 #1
  • viewed: 2783
Share:
6 Replies
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)

Rob Meade wrote:
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

Jan 30 '07 #2
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
Jan 30 '07 #3
"darrel" wrote ...
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 :o/
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 :o)

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
Jan 31 '07 #4
"bruce barker" wrote ...
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
Jan 31 '07 #5
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
Jan 31 '07 #6
"darrel" wrote ...
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
Feb 1 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Miguel Dias Moura | last post: by
1 post views Thread by msnews.microsoft.com | last post: by
13 posts views Thread by Leszek Taratuta | last post: by
reply views Thread by arunprabu@gmail.com | last post: by
1 post views Thread by 47computers@gmail.com | last post: by
11 posts views Thread by =?Utf-8?B?R2VyaGFyZA==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.