What are the best ways to stay with a selected item in a select after page transition (Go to a page and then return with the fields already selected) using ASP.NET MVC? Session? Cache? TempData? Hidden field?
What are the best ways to stay with a selected item in a select after page transition (Go to a page and then return with the fields already selected) using ASP.NET MVC? Session? Cache? TempData? Hidden field?
GET
This is what the GET
parameterization has been done: to keep the filters in a page change.
I'm assuming you have a <form>
in your View :
@using (Html.BeginForm()) { ... }
By default, forms in ASP.NET MVC are POST
, but nothing prevents us from using this way:
@using (Html.BeginForm("Pesquisa", "MeuController", FormMethod.Get)) { ... }
When submitting your form, you will notice that the parameters you entered will all go to the address bar. If you reposition the form within the search result screen, you'll see that the filters are populated.