Adding CSS class to Html.BeginForm()
How to add class attribute for following situation (Using ReturnUrl only):
@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }))
{
}
I want something like this:
@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }, new { @class = "login-form" }))
{
}
Solution 1:
There is an overload for that, if you supply the controller action, name, and form method.
@using (Html.BeginForm("ActionName", "ControllerName",
new { ReturnUrl = ViewBag.ReturnUrl },
FormMethod.Post, new { @class="login-form" }))
{
etc.
}
Solution 2:
Html.BeginForm("Index", "EIApplication", FormMethod.Post, new { enctype = "multipart/form-data", **@class = "nea-forms"** })