Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html.BeginForm and HTML Attributes w/o specifying Controller and Action

Tags:

I like the cleanliness of

using (Html.BeginForm()) 

And hate that adding HTML attributes requires specifying the controller, action, and form method.

using (Html.BeginForm("Action", "Controller", FormMethod.Post,   new { id = "inactivate-form" }) 

Is there a way to use Html.BeginForm and specify HTML attributes for the form without manually wiring everything else up?

like image 234
ahsteele Avatar asked Nov 23 '09 22:11

ahsteele


People also ask

What is HTML BeginForm?

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. BeginForm extension method in ASP.NET MVC5. BeginForm("ActionMethod", "ControllerName","Get⁄Post Method")

What is @using HTML BeginForm ()) in MVC?

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)

What is difference between HTML BeginForm and ajax BeginForm?

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.

Which two objects can you passed as a parameter to the HTML helper Dot BeginForm method?

In the "BeginForm()" method we passed an action name and controller name so that the action method will be called that handles the post data request.


1 Answers

Why would you not just use plain html?

<form id="inactivate-form" method="post" > </form> 
like image 92
Simon Fox Avatar answered Sep 22 '22 16:09

Simon Fox