I have a controller “Contracts” and 3 GET methods: “All”, “Focus”, which contains grid, and “Edit” for editing, and one POST method: “Edit”.
Users can access to Edit from any grid by using button. But after POST executed, i want to redirect them to action that send request.
For example:
- open “Focus” grid
- select row
- clicked edit
- make changes, and click save
- finally redirect to “Focus” grid (!)
or
- open “All” grid
- select row
- clicked edit
- make changes, and click save
- finally redirect to “All” grid (!)
in the
AllView you will have the grid with the data. Selecting a record from the Grid and clicking Edit will take you to the second Action method for Edit.You may pass a some flag when calling the edit method here. You may add that when you build the edit link like this
So my Edit will have a querystring key “
from” with a value “all“Same way,in your the View for your
Focus, you may pass a different valueNow the Edit Action method, You read the parameter and set it as the property value of our edit view model. you may want to add this property to your ViewModel.
and this View will have the edit form. We will keep the value of
Frominside a form element so that we can use that on the form post.Where user can edit and submit it again . you handle that in the HttpPost Edit action method. Check the From property value and decide where to redirect after saving