Having a persistent dropdownlist value through site navigation

513 Views Asked by At

I have a html drop down list in my web site. When the user selects a particular item in the list I want it to be shown in all the pages when the user navigates through the site.How Can I do that??

I am using visual studio 2010 and mvc3 views. Currently what happen is when the user selects a particular item,the selected value only stays for the current page, when I go to another page, the default value, which is the very first item in the list is shown.

How can I have persistent dropdown list value?? Thanks.

1

There are 1 best solutions below

2
On

There are different ways to achieve this. You could store it in Session or Cookies. So for example on the first page create a form containing the DropDown with a submit button. When the user clicks on the submit button the form will post the selected value back to the server and the server could either store it in Session or client side cookie. Then the controller action could redirect to some other action which will be able to retrieve the value. And from now on this value will be available on all subsequent requests.