There are various types of techniques to submit a form in ASP.NET MVC. This is a series of 4 articles where you will learn various ways of form submission while working in ASP.NET MVC.
This article will increase your knowledge not only of Form Submission but also about the basic terminology of ASP.NET MVC Forms.
Flow of article
In this article, you will learn the following concepts.
- What is Form Submit?
- How many ways to submit the Form?
- Short Notes on various ways of Form Submission.
- What is @Html.BeginForm?
- Syntax of @Html.BeginForm?
- Explanation of various overloaded methods of HTML.BeginForm.
- What is RouteValues?
- What is HtmlAttributes?
- What is FormMethod?
- Task
- Step-by-Step Implementation of @Html.BeginForm
(We will do a POST with @Html.BeginForm)
- Fast Recap.
What is Form Submit (Submission)?
The user fills in the form/page and sends the entered details to the server. In the end, we want information; and the user details should be saved on the server.
How many ways are there to submit a Form in ASP.NET MVC
Following are the ways to submit the form.
- @Html.BeginForm with hard-code Action.
- @Ajax.BeginForm with hard-code Action.
- HTML Input Submit Button using FormAction, FormMethod attributes.
- Using jQuery set form Action property.
- Using jQuery AJAX with FormData.
- Using jQuery AJAX with serializeFormJSON.
Short notes
@Html.BeginForm
BeginForm is an extension method of the @HtmlHelper class and is used for creating and rendering the form tag in HTML.
For more detail visit this link.
@Ajax.BeginForm
BeginForm is an extension method of @AjaxHelper classes and is used for creating and rendering the form tag in HTML. @Ajax.BeginForm The Helper method submits the form asynchronously using JavaScript.
For more detail visit the link.
HTML Submit Button using FormAction, FormMehod
This information attribute is new in HTML5 using INPUT type “submit”. The form method attribute is where we can define the method of submission as “POST” or “GET”.
For more detail visit this link.
Using jQuery set form Action property
We can change the action property using jQuery and submit the form on the desired action.
For more detail visit this link.
Using jQuery AJAX with FormData
We can submit the Form using jQuery Ajax with FormData. It's a very simple and fast way to submit the form. FormData is used to create an object and pass the form data. This method or way is not good for more field forms because we have to assign manually the value of form control to the FormData object and property.
For more detail visit this link.
Using jQuery AJAX with serializeFormJSON
Using serializeFormJSON will auto-pick the value and generate the object that we can get in the POST action method.
What is @Html.BeginForm?
BeginForm is a @Html helper method used to render FormTag as well as to post data from view (Form Data ) to the controller.
@Html.BeginForm reduced our work -- you have to just specify your ACTION, CONTROLLER, and TYPE OF METHOD.
For using this System.Web.Mvc namespace and System.Web.Mvc.dll files are required. By default, in all MVC projects, System.Web.The mvc namespace is already used. @Html helper method is derived from System.Web.Mvc.

In the above image, you can see HTMLHELPER derived from System.Web.Mvc.
Syntax of @Html.BeginForm?
@Html.BeginForm()
There are a total of 13 overloaded ways to use and implement @Html.BeginForm.
In most projects, I used the following overloaded way.
- @Html.BeginForm(“ActionMethod”,” CotrollerName”)
- @Html.BeginForm(“ActionMethod”,” CotrollerName”,” FormMethod”)
- @Html.BeginForm(“ActionMethod”,” CotrollerName”,” RouteValues”,” FormMethod”)
- @Html.BeginForm(“ActionMethod”,” CotrollerName”,” FormMethod”,” HtmlAttributes”)
How does @Html.BeginForm work?
@Html.BeginForm posts the form to the server.
Type1
@using (@Html.BeginForm())
{
}
The above goes to the same action method name but on the POST side.
Type2
@Html.BeginForm("ActionMethod", "ControllerName", FormMethod)
This example form is called “ActionMethod” of “ControllerName” with specific “FormMethod”.
E.g.
@Html.BeginForm("detail", "EmployeeController", FormMethod.Post)
What is RouteValues?
Which data travel along with ActionMethod and Controller.
E.g. http://www.maonjbkalla.weebly.com/courses
(In the above URL, you can see there are no route values)
E.g. http://www.maonjbkalla.weebly.com/courses/1
(In the above URL you can see 1 is the route value)
Route values accepted by action method.
What is HtmlAttributes?
We can add HtmlAttributes in @Html.BeginForm. HTML attributes like ID, CLASS, STYLE, etc.
Syntax
@Html.BeginForm(action, controller, FormMethod, htmlAttributes)
E.g
@Html.BeginForm("employeelist", "employee", FormMethod.Post, new { id = "formid" })
What is FormMethod?
FormMethod is a command that executes form as POST or GET. FormMethod made HTTP requests either in GET or POST form.
E.g
@Html.BeginForm("Login", "Home", FormMethod.Post, new { id = "formname" })
Task
We have to create the following screen send the entered data to the server and store it in a database table.

We will be doing the following to complete the task
- Create a Table called tblFriends.
- Create Asp.Net MVC Project.
- Create Code First Entity Framework dbContext classes.
- Create Model FriendModel.
- Create an ActionMethod called “FriendDetail” inside HomeController.
- Create a view called “FriendDetail”
Step-by-step implementation of @Html.BeginForm
Table Structure
CREATE TABLE [dbo].[tblFriends](
[FriendID] [int] IDENTITY(1,1) NOT NULL,
NULL,
NULL,
NULL,
PRIMARY KEY CLUSTERED
(
[FriendID] ASC
)
WITH
(
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
)
ON [PRIMARY]
)
ON [PRIMARY]
Insert Query Sample Records













Balasubramanian RPosted Oct 1, 2022, 3:47 PM
I have a problem with post. I am posting form by creating formdata and appending file & some data. Using Ajax posting to controller action. In action insert the excel data in table and return this records in jsonresult. Now in ajax success parsing the json and displaying the records in html table with paging. Now i am unable to click anywhere in the application. What is wrong? please suggest. Thanks
DeepanPosted Sep 19, 2019, 2:56 AM
Good article sir
Sourav Kumar DasPosted Aug 22, 2019, 11:40 PM
Nice Article Sir.
Amit MohantyPosted Aug 22, 2019, 11:09 PM
Nice article