user8103
user8103

Reputation: 309

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"})

Upvotes: 16

Views: 35998

Answers (1)

Ashwini Verma
Ashwini Verma

Reputation: 7525

We add as part of htmlAttributes.

@Html.BeginForm("actionName", "controllerName", FormMethod.Post,
 new {id="frmId", @class = "frmStyle"})

Upvotes: 36

Related Questions