user8103 user8103 - 1 year ago 149
ASP.NET (C#) Question

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

I tried this but got error.

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

Answer Source

We add as part of htmlAttributes.

@Html.BeginForm("actionName", "controllerName", FormMethod.Post,
 new {id="frmId", @class = "frmStyle"})
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download