3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RazorPagesで1Form内の複数SubmitボタンでPostハンドラメソッドを切り分ける方法

Last updated at Posted at 2020-09-21

1Form内の複数SubmitボタンでPostハンドラメソッドを切り分ける方法
環境: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>
Index.cshtml.cs
public class IndexPage : PageModel
{
	public void OnPostView()
	{
	}
	public void OnPostPrev()
	{
	}
	public void OnPostNext()
	{
	}
}

参考:

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

複数ボタンのあるFormで押されたボタンを判断する
https://qiita.com/echoprogress/items/17e85ad489bddf07b540

ASP.NET Core MVC 複数ボタンのあるFormでSubmit先を変えたい
http://heinlein.hatenablog.com/entry/2018/02/21/151026

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?