Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mvc add id and css class in MVC Html.BeginForm()

I am new to MVC.

How I can add id and css class in MVC Html.BeginForm().

This is html form.

<form id="frmId" class="frmStyle">
    ...
</form>

I tried this but got error.

@Html.BeginForm("actionName", "controllerName", new {id="frmId", class = "frmStyle"})
like image 243
user8103 Avatar asked Apr 14 '14 14:04

user8103


People also ask

What is the use of Html BeginForm in MVC?

Html. BeginForm is the Html Helper Extension Method that is used for creating and rendering the form in HTML. This method makes your job easier in creating form. Here, is the method to create a form using Html.

What is the difference between Ajax BeginForm and HTML BeginForm?

Html. BeginForm() will create a form on the page that submits its values to the server as a synchronous HTTP request, refreshing the entire page in the process. Ajax. BeginForm() creates a form that submits its values using an asynchronous ajax request.


1 Answers

We add as part of htmlAttributes.

@Html.BeginForm("actionName", "controllerName", FormMethod.Post,
 new {id="frmId", @class = "frmStyle"})
like image 161
Ashwini Verma Avatar answered Oct 08 '22 08:10

Ashwini Verma