Adding CSS class to Html.BeginForm()
.net, asp.net-mvc-4, css, forms, html-helper
Solution
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.
}
Problem
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" })) { } ```