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" })) { }
BeginForm(HtmlHelper) Writes an opening <form> tag to the response. The form uses the POST method, and the request is processed by the action method for the view. BeginForm(HtmlHelper, String, String, Object, FormMethod, Object)
Thanks for your help ! Multiple form tags should work fine in MVC unless they are nested.
BeginForm() method has three arguments, these are actionName, controllerName and AjaxOptions.
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. }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With