The "save" submit button brings user back to the index view (assignment.index). I would like to bring user to an alternate view (assignment.contact).
This depends on the return value of the POST action of submit button.
For example:
I guess your post action is like:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Assignment model)
{
...
if (ModelState.IsValid)
{
db.Entry(model).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");//if you save successfully,it will jump to Index view
}
...
return View(model);//If the save failed,it will return to the Edit view.
}
if you would like to Contact view after clicking the "save" button,
I think you just modify the code,like:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Assignment model)
{
...
if (ModelState.IsValid)
{
db.Entry(model).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Contact");//if you save successfully,it will jump to Contact view
}
...
return View(model);//If the save failed,it still return to the Edit view.
}
Best Regards.
Yuki Tao
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
361 Points
823 Posts
Submit / Save button destination
Mar 13, 2019 08:39 PM|3v3rhart|LINK
The "save" submit button brings user back to the index view (assignment.index). I would like to bring user to an alternate view (assignment.contact).
All-Star
52101 Points
23231 Posts
Re: Submit / Save button destination
Mar 13, 2019 08:51 PM|mgebhard|LINK
This is handled in the Action. Remember, Views are NOT invoked directly. Actions are methods that return Views.
This ActionLink helper simply creates a link according to the input parameters you supplied.
if you want to generate a different link then add an "IF" that renders what you want or use variables.
Contributor
3710 Points
1431 Posts
Re: Submit / Save button destination
Mar 14, 2019 03:17 AM|Yuki Tao|LINK
Hi 3v3rhart,
This depends on the return value of the POST action of submit button.
For example:
I guess your post action is like:
if you would like to Contact view after clicking the "save" button,
I think you just modify the code,like:
Best Regards.
Yuki Tao
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.