How to isolate Post handler method with multiple Submit buttons in 1Form in RazorPages
How to isolate Post handler method with multiple Submit buttons in 1Form
Environment: ASP.NET core 3.1, Visual Studio 2019
Index.cshtml
<form method="post">
<button type="submit" asp-page-handler="View">View</button>
<button type="submit" asp-page-handler="Prev">Prev</button>
<button type="submit" asp-page-handler="Next">Next</button>
</form>
cs:Index.cshtml.cs
public class IndexPage : PageModel
{
public void OnPostView()
{
}
public void OnPostPrev()
{
}
public void OnPostNext()
{
}
}
reference:
How to distinguish multiple buttons in ASP.NET Core MVC?
https://ja.stackoverflow.com/questions/47925/asp-net-core-mvc%E3%81%A7-%E8%A4%87%E6%95%B0%E3%83%9C%E3%82%BF%E3%83%B3%E3%82%92%E5%8C%BA%E5%88%A5%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF
Determine which button was pressed on a Form with multiple buttons
https://qiita.com/echoprogress/items/17e85ad489bddf07b540
ASP.NET Core MVC I want to change the submit destination on a Form with multiple buttons
http://heinlein.hatenablog.com/entry/2018/02/21/151026