开发者

Google Chrome issue - Unable to retrive button(HTML tag) value while submitting form

开发者 https://www.devze.com 2023-04-08 04:44 出处:网络
I have a scenario in which a button value is not being posted while submitting form in ASP.NET MVC controller.

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号