有一些简单的方法可以处理来自同一表单的多个提交按钮吗?例如:
<% Html.BeginForm("MyAction", "MyController", FormMethod.Post); %>
<input type="submit" value="Send" />
<input type="submit" value="Cancel" />
<% Html.EndForm(); %>
任何想法如何在ASP.NET Framework Beta中做到这一点?我搜索过的所有示例中都包含一个按钮。
Modified version of
HttpParamActionAttribute
method but with a bug fix for not causing an error on expired/invalid session postbacks. To see if this is a problem with your current site, open the your form in a window and just before you go to clickSave
orPublish
, open a duplicate window, and logout. Now go back to your first window and try to submit your form using either button. For me I got an error so this change solves that problem for me. I omit a bunch of stuff for the sake of brevity but you should get the idea. The key parts are the inclusion ofActionName
on the attribute and making sure the name passed in is the name of the View that shows the formAttribute Class
Controller
View