我该如何命名与Html.BeginForm()形式? [英] How can I name a form with Html.BeginForm()?
本文介绍了我该如何命名与Html.BeginForm()形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何提供一个名称使用ASP.NET MVC形式 Html.BeginForm()
? 我想只有名称,没有动作或控制器名称,因为我想通过JavaScript将它张贴。我想应该是这样的 Html.BeginForm(ID =FRM)
。
我试过如下:
Html.BeginForm(NULL,NULL,新{ID =FRMNAME =FRM})Html.BeginForm(新{@ ID =FRM,@ NAME =FRM})
但上面的code会产生这样的输出:
<形式的行动=/?主/索引/ ID名称= ID的方法=后>
解决方案
Html.BeginForm(NULL,NULL,FormMethod.Get,新{NAME =FRMID =FRM })
您需要赶上表格你的JavaScript
提交How do I give a name to a form in ASP.NET MVC using Html.BeginForm()
? I want only the name, not the action or controller name because I want to post it through Javascript. I think it should be something like Html.BeginForm(id = "frm")
.
I tried the following:
Html.BeginForm(null,null,new{id="frm",name="frm})
Html.BeginForm(new{@id="frm",@name="frm})
But the above code produces output like this:
<form action="/Main/Index/Id?name=Id" method="post">
解决方案
Html.BeginForm(null, null, FormMethod.Get, new { name = "frm", id = "frm" })
You'll need to catch the form submit with your JavaScript
这篇关于我该如何命名与Html.BeginForm()形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文