Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i maintain the value of dropdownlist on browser back button click. i have five fix items on my dropdown and i did not bind it via code. just add list items on the source file of aspx. now when user go to next page and click browser back button i want to maintain the value of the dropdown which was last selected ?
Posted
Comments
[no name] 21-Jan-14 8:29am    
You can use Session to store the selected value for dropdown list.
and after browser back button is clicked , check for that session is not null and get your selected value.
If you want code for it, let me know.
ravikhoda 21-Jan-14 8:32am    
yes please..i think that i will need the code. i tried the session on page load but i think on the back button click of browser page is load from the cache and not from the server so page load event not called and not getting exact result, please share some code if you have.

thanks in advanced
[no name] 21-Jan-14 8:41am    
inside DropDownSelectedIndexChanged event , put Session["SelectedIndex"] = dropdown1.SelectedIndex;

and in page_load event
{
If(!IsPostBack)
{
If(Session["SelectedValue"]!=null)
dropdown1.SelectedIndex = Convert.toInt32(Session["SelectedIndex"].toString());
}
}
ravikhoda 21-Jan-14 22:58pm    
thanks this works great :)

1 solution

The back button click of browser page is loaded from the cache and not from the server.
Use session to store selected item in dropdownlist, session values is available across asp.net pages.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900