How to add ID property to Html.BeginForm() in asp.net mvc?

后端 未结 4 1129
慢半拍i
慢半拍i 2020-12-12 23:03

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...



        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 23:41

    In System.Web.Mvc.Html ( in System.Web.Mvc.dll ) the begin form is defined like:- Details

    BeginForm ( this HtmlHelper htmlHelper, string actionName, string
    controllerName, object routeValues, FormMethod method, object htmlAttributes)

    Means you should use like this :

    Html.BeginForm( string actionName, string controllerName,object routeValues, FormMethod method, object htmlAttributes)

    So, it worked in MVC 4

    @using (Html.BeginForm(null, null, new { @id = string.Empty }, FormMethod.Post,
        new { @id = "signupform" }))
    {
        
        
    }
    

提交回复
热议问题