Google Chrome issue - Unable to retrive button(HTML tag) value while submitting form
I have a scenario in which a button value is not being posted while submitting form in ASP.NET MVC controller.
This is happening only for Google Chrome browser. For all other browsers Firefox, IE, I am getting Submit_0 value in Controller.
//Server side
public ActionResult Answers(string id, Survey开发者_如何学运维ViewModel model, string Submit, string button)
{
string[] buttonParts = button.Split(new char[]{'_'});
..
...
}
//Client Side
@using (Html.BeginForm("Answers", "Survey"))
{
<button value="Submit_0" name="button" onclick="document.forms[0].submit();"><span><span>Submit</span></span></button>
}
Kindly suggest.
I wonder if it is because the way you wired the button. Why don't you use something like this instead?
<button type="submit" name="button" value="submit_0">Submit</button>
Notice that the button has a type of submit (which eliminate the need to call document.forms[0].submit() manually)
精彩评论