我的 asp.net mvc (C#) 应用程序中有一个带有两个提交按钮的表单。当我点击任何提交按钮时Google Chrome
,默认情况下提交按钮的值是第一个提交按钮的值。
这是html:
<input type="submit" value="Send" name="SendEmail" />
<input type="submit" value="Save As Draft" name="SendEmail" />
<input type="button" value="Cancel" />
当我单击Save As Draft
按钮时,在控制器的操作中,它将“发送”作为SendEmail
.
这是动作:
public ActionResult SendEmail(string SendEmail, FormCollection form)
{
if(SendEmail == "Send")
{
//Send Email
}
else
{
//Save as draft
}
return RedirectToAction("SendEmailSuccess");
}
当我从 FormCollection 获取值时,它显示“发送”。即form["SendEmail"]
给Send
我需要做些什么才能获得单击的提交按钮的实际值可能是什么问题或解决方法?