How do I stay with the selected item in a select after page transition?

2

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?

    
asked by anonymous 01.06.2016 / 19:16

1 answer

2

GET

This is what the GET parameterization has been done: to keep the filters in a page change.

How do you use it?

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.

I have listed all this in this answer .

    
01.06.2016 / 19:53