Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9374

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

$
0
0

1Form内の複数SubmitボタンでPostハンドラメソッドを切り分ける方法
環境:ASP.NET core 3.1, Visual Studio 2019

Index.cshtml
<formmethod="post"><buttontype="submit"asp-page-handler="View">View</button><buttontype="submit"asp-page-handler="Prev">Prev</button><buttontype="submit"asp-page-handler="Next">Next</button></form>
Index.cshtml.cs
publicclassIndexPage:PageModel{publicvoidOnPostView(){}publicvoidOnPostPrev(){}publicvoidOnPostNext(){}}

参考:

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


Viewing all articles
Browse latest Browse all 9374

Latest Images

Trending Articles