DAY Communications LLC Design & Function for Web & Print

Retaining Asp.net DropDownList selection on return from linked page

I spent numerous hours researching if a view resulting from a selection in a DropDownList could be retained after clicking to a new page. This was needed for a school website in order to select the list of classes of a particular discipline, then click on a class, go to a new page, and return to the selected class list.

I explored lots of options, but finally implemented a simple solution----

Add a javascript: function goBack() with window.history.back() as the definition of the function. Then put a button on the visited razor view page to go back to the page that has the DropDownList with onclick="goBack()" within the button tag. This is a client solution that uses the browser's cache functionality.

Previously there was a Html.ActionLink to return to the Index page. This resulted in a view of all content, not the previously selected course list.

Please comment if you like this solution, or feel it will eventually cause a dilemma.

Comments are closed