如何在asp.net mvc的ID属性添加到Html.BeginForm()? [英] How to add ID property to Html.BeginForm() in asp.net mvc?
本文介绍了如何在asp.net mvc的ID属性添加到Html.BeginForm()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用jQuery来验证我的形式,但它不具有 ID
属性截至目前如何将它添加到asp.net mvc的形式?我用这...
I want to validate my form using jquery but it doesn't have an ID
property as of now how to add it to the form in asp.net mvc? I am using this...
<% using (Html.BeginForm()) {%>
和我的jQuery插件验证借此,
and my jquery validator plugin takes this,
var validator = $("#signupform").validate({
现在我想给id作为 signupform
...任何建议...
Now i want to give id as signupform
... Any suggestion...
推荐答案
这应该得到添加了id。
This should get the id added.
ASP.NET MVC 5和更低的:
ASP.NET MVC 5 and lower:
<% using (Html.BeginForm(null, null, FormMethod.Post, new { id = "signupform" }))
{ } %>
ASP.NET 1.0的核心MVC:您可以使用标签佣工,以避免奇怪的语法设置id
ASP.NET Core 1.0 MVC: You can use tag helpers to avoid the odd syntax for setting the id.
<form asp-controller="Account" asp-action="Register" method="post" id="signupform" role="form"></form>
这篇关于如何在asp.net mvc的ID属性添加到Html.BeginForm()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文