Google Chrome 问题 - 提交表单时无法检索按钮(HTML 标记)值
我有一个场景,在 ASP.NET MVC 控制器中提交表单时未发布按钮值。
仅 Google Chrome 浏览器才会出现这种情况。对于所有其他浏览器 Firefox、IE,我在控制器中获取 Submit_0 值。
//服务器端
public ActionResult Answers(string id, SurveyViewModel model, string Submit, string button)
{
string[] buttonParts = button.Split(new char[]{'_'});
..
...
}
//客户端
@using (Html.BeginForm("Answers", "Survey"))
{
<button value="Submit_0" name="button" onclick="document.forms[0].submit();"><span><span>Submit</span></span></button>
}
请建议。
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, SurveyViewModel 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想知道这是否是因为你连接按钮的方式。你为什么不使用这样的东西来代替呢?
请注意,该按钮具有提交类型(这消除了手动调用 document.forms[0].submit() 的需要)
I wonder if it is because the way you wired the button. Why don't you use something like this instead?
Notice that the button has a type of submit (which eliminate the need to call document.forms[0].submit() manually)