Return to previous view with data filled in

Asked

Viewed 557 times

1

I have 3 View’s, a main (Index) containing fields to perform filters and a search button, another ,Gridindex (rendered inside the Index view), where records are demonstrated based on search filters, and a third (Information) which is displayed when the user clicks on an existing button in Gridindex.

When the user accesses the information view, and goes back to the previous page, only the Index view is displayed, forcing the user to click the search button again to display the records.

There is a way, when the user goes back to the previous page, in addition to the Index, to display the filled Gridindex?

1 answer

2


Use GET instead of POST:

@using (Html.BeginForm("Acao", "Controller", FormMethod.Get))
{
    ...
}

To Action who receives the POST must allow GET also:

[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult Index(ObjetoPesquisa objPesquisa) 
{
    ...
}

In the GET your search data is preserved in the URL, unlike POST. To work on POST, it would be necessary to store everything in Session, what is not recommended.

Browser other questions tagged

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