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"})
Html. BeginForm is the Html Helper Extension Method that is used for creating and rendering the form in HTML. This method makes your job easier in creating form. Here, is the method to create a form using Html.
Html. BeginForm() will create a form on the page that submits its values to the server as a synchronous HTTP request, refreshing the entire page in the process. Ajax. BeginForm() creates a form that submits its values using an asynchronous ajax request.
We add as part of htmlAttributes.
@Html.BeginForm("actionName", "controllerName", FormMethod.Post,
new {id="frmId", @class = "frmStyle"})
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