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

Asked

Viewed 51 times

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 already selected fields) using ASP.NET MVC? Session? Cache? Tempdata? Hidden field?

  • Depends... has how to explain more your scenario?

  • I put a filter on a page, access the detail of an item that is already filtered in a table (On another page). I have the option to return to the previous page, but I would like it to remain with the filters I had already done.

  • You can create a Single page application or save all this somewhere, I think in the cache of the quiet

1 answer

2

GET

That’s why the parameterization GET was made: so that, in a page change, the filters remain.

How is the use of this?

I’m guessing you have one <form> at some View your:

@using (Html.BeginForm()) { ... }

By default, forms in ASP.NET MVC are POST, but nothing stops us from using like this:

@using (Html.BeginForm("Pesquisa", "MeuController", FormMethod.Get)) { ... }

When submitting your form, you will notice that the completed parameters will all go to the address bar. If you place the form inside the search result screen, you will see that the filters are filled.

I have detailed all this in this reply.

  • In my case, it’s not a form, it’s a few dropdowns, as it would look?

  • Please edit your question and ask how are the Dropdowns.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.