Introduction
This article will explain standard HTML Helpers in MVC. Standard HTML helpers render HTML controls like Anchor, Label, Hidden Input, TextBox, TextArea, DrpdownList, RadioButton, CheckBox, ListBox, Password Input, and HTML Form etc. We can use as per our requirement.
List of standard HTML Helpers
- @Html.BeginForm
- @Html.ActionLink
- @Html.Label
- @Html.Hidden
- @Html.TextBox
- @Html.TextArea
- @Html.Password
- @Html.RadioButton
- @Html.CheckBox
- @Html.ListBox
- @Html.DropdownList
Step 1
Screenshot for creating new project-1

After clicking on New Project one window will appear. Select Web from left panel and choose ASP.NET Web Application to give a meaningful name to your project then click on OK as shown in the below screenshot.
Screenshot for creating new project-2

After clicking on OK, one more window will appear. Choose Empty, check on MVC checkbox and click on OK as shown in the below screenshot.
Screenshot for creating new project-3

After clicking on OK, a project will be created with the name of StandardHTML_Hekper_Demo.
Step 2
Screenshot for adding controller

After clicking on the controller, a window will appear to choose MVC5 Controller-Empty -- click on Add.

After clicking on Add, another window will appear with DefaultController. Change the name to HomeController then click on Add.

Step 3
Screenshot for adding view

@Html.BeginForm
- @using (Html.BeginForm("Index", "Home", FormMethod.Post))
- {
- }
@Html.ActionLink
- @Html.ActionLink ("Home", "Index")
Output

@Html.Label
- @Html.Label("firstName", "First Name")

@Html.Hidden
- @Html.Hidden("EmployeeId", "")
@Html.TextBox
- @Html.TextBox("txtFirstName", "", new { @class = "form-control", placeholder = "First Name" })

@Html.TextArea
- @Html.TextArea("address", new { @class = "form-control", rows = "5" })

@Html.Password
- @Html.Password("password", " ", new { @class = "form-control" })
@Html.RadioButton
- <div class="btn-group" data-toggle="buttons">
- <label class="btn btn-primary active">
- @Html.RadioButton("MaritalStatus", "Married", true, new { id = "IsMarried" }) Married
- </label>
- <label class="btn btn-primary">
- @Html.RadioButton("MaritalStatus", "Unmarried", false, new { id = "IsUnmarried" }) Unmarried
- </label>
- </div>
@Html.CheckBox
- <div class="btn-group" data-toggle="buttons">
- <label class="btn btn-primary">
- <span class="glyphicon glyphicon-unchecked"></span>
- @Html.CheckBox("htmlSkill", true) HTML 5
- </label>
- <label class="btn btn-primary active">
- <span class="glyphicon glyphicon-ok-circle"></span>
- @Html.CheckBox("cssSkill") CSS3
- </label>
- <label class="btn btn-primary">
- <span class="glyphicon glyphicon-unchecked"></span>
- @Html.CheckBox("bootstrapSkill", false) Bootstrap 4
- </label>
- </div>
Html.ListBox
- @Html.ListBox("Skills",new List<SelectListItem> {
- new SelectListItem { Text="ASP.NET",Value="1"},
- new SelectListItem { Text="MVC",Value="2"},
- new SelectListItem { Text="SQL Server",Value="3"},
- new SelectListItem { Text="Angular",Value="4"},
- new SelectListItem { Text="Web API",Value="5"}
- },new { @class="form-control"})
Output
@Html.DropdownList
- @Html.DropDownList("Gender", new List<SelectListItem> {
- new SelectListItem {Text="Select Gender",Value="-1" },
- new SelectListItem {Text="Male",Value="1" },
- new SelectListItem {Text="Female", Value="2" }
- }, new { @class = "custom-select" })
Output


Amit Kumar SinghPosted Nov 5, 2018, 11:51 PM
Nice one... Thanks for sharing !!!