Member_2_4458446
asked on
Change URL value when a dropdown index in AJAX update panel selected index changes
I want to change the URL in the address bar of the browser when a dropdown index in AJAX update panel selected index changes
I have a page which by default is http://www.example.com/default.aspx
A drop down in an update panel has a series of values.
You can also open it by entering http://www.example.com/default.aspx?value=2 in the address bar. It will select the value '2' in the dropdown and display the right results in the update panel.
When a user selects a value from the dropdown (let's say they pick value 2), I would like the url to become http://www.example.com/default.aspx?value=2
I have a page which by default is http://www.example.com/default.aspx
A drop down in an update panel has a series of values.
You can also open it by entering http://www.example.com/default.aspx?value=2 in the address bar. It will select the value '2' in the dropdown and display the right results in the update panel.
When a user selects a value from the dropdown (let's say they pick value 2), I would like the url to become http://www.example.com/default.aspx?value=2
ASKER
Using clientside hashes sounds good but I'm a little confused on how to:
"you can get this info on the client using document.location.hash (result: value=2) then parse it to get your value, then get the data for this record using AJAX"
How can I interject my own JS during an ASP UpdatePanel update?
I have a gridview with data tied to a dropdown. Both are in an update panel. Should I map my own JS to get the value of the hash when the selectedindex of the drop down changes, and then more importantly, how do I make sure the server knows what it is and that I can reference it in my codebehind file to pull up the right data?
Thanks!
"you can get this info on the client using document.location.hash (result: value=2) then parse it to get your value, then get the data for this record using AJAX"
How can I interject my own JS during an ASP UpdatePanel update?
I have a gridview with data tied to a dropdown. Both are in an update panel. Should I map my own JS to get the value of the hash when the selectedindex of the drop down changes, and then more importantly, how do I make sure the server knows what it is and that I can reference it in my codebehind file to pull up the right data?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome explanation, thank you so much!
A solution I came up is to use the hash instsead - altering this does not trigger a page refresh
so your url would be
http://www.example.com/default.aspx#value=2
you can get this info on the client using document.location.hash (result: value=2) then parse it to get your value, then get the data for this record using AJAX
when you want to change it, simply set document.location.hash again