I have a form with two submit buttons in my asp.net mvc (C#) application. When i click any submit button in Google Chrome
, by default the value of submit button is the first submit button's value.
Here is the html:
<input type="submit" value="Send" name="SendEmail" />
<input type="submit" value="Save As Draft" name="SendEmail" />
<input type="button" value="Cancel" />
When i click the Save As Draft
button, in the action of the controller, it gets "Send" as the value for SendEmail
.
Here is the action:
public ActionResult SendEmail(string SendEmail, FormCollection form)
{
if(SendEmail == "Send")
{
//Send Email
}
else
{
//Save as draft
}
return RedirectToAction("SendEmailSuccess");
}
When i get the value from FormCollection, it shows "Send". i.e. form["SendEmail"]
gives Send
What may be the problem or work around i need to do to get the actual value of the clicked submit button?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…