I want to create a form which has no default action in it.
I tried doing Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data", id = "AppForm" })
but it assigns the current action method name to the action part of the form and renders it as
<form class="ng-pristine ng-valid" id="AppForm" action="/Portal/on/application" enctype="multipart/form-data" method="post" novalidate="novalidate">
</form>
I have two separate buttons on the form and I am following this article http://stackoverflow.com/questions/442704/how-do-you-handle-multiple-submit-buttons-in-asp-net-mvc-framework
to create a form but not sure how to create one which has no action.
Thanks
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.
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.
BeginForm(HtmlHelper, String, String, FormMethod, Object)Writes an opening <form> tag to the response and sets the action tag to the specified controller and action. The form uses the specified HTTP method and includes the HTML attributes.
BeginForm() method has three arguments, these are actionName, controllerName and AjaxOptions.
Do you have to use Html.BeginForm()
? You could just do it with html instead of using the HtmlHelper
.
<form class="ng-pristine ng-valid" id="AppForm" action="" enctype="multipart/form-data" method="post" novalidate="novalidate">
</form>
If you have to use the HtmlHelper, you can override the form action like this:
@using(Html.BeginForm(null, null, FormMethod.Post, new { @action = "", enctype = "multipart/form-data", id = "AppForm" })) {
}
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