What is HTML helper?
An HTML helper is a method that is used to render html content in a view. HTML helpers are implemented as extension methods. For example, you can use HTML Helpers to render standard HTML tags like HTML <input>, <button> and <img> tags etc.
You can also create your own HTML Helpers to render more complex content such as a menu strip or an HTML table for displaying database data.

<input type="text" name="firstname" id="firstname"/>
The above HTML line produce the HTML for a textbox with id="firstname" and name="firstname". The similar code using using HTML helper is as follows:


@Html.TextBox("firstname")
If we see the page source in browser it will generate the same html code as shown in the following screen

The same with its overloaded version are for example with value and name as follows:
@Html.TextBox("firstname", "Smith")

Its not mandatory to use HTML helper in ASP.NET MVC but using HTML helper will greatly reduce the amount of HTML that we have to write in a view. It can be say that all the complicated logic to generate a control can be encapsulated into the helper which helps
to keep view simple as much possible.
HTML Helpers are categorized into three types:
- Inline HTML Helpers
- Built-in HTML Helpers
- Custom HTML Helpers
Built-in HTML Helpers are further divided into three categories:
- Standard HTML Helpers
- Strongly Typed HTML Helpers
- Templated HTML Helpers
Standard HTML Helpers
Standard HTML Helpers use to render the most common type of HTML controls like TextBox, DropDown, Radio buttons, Checkbox etc.
Strongly Typed Helper method
Strongly Typed Helper requires lambda expressions. For using Strongly Typed Helper method, Firstly We have to make Strongly Typed View.
Template Helper Method
These methods are very flexible and generate the HTML element based on the properties of the model class. Here is the list of all HTML helpers in MVC
Html Control |
Strogly Typed HtmlHelpers |
Html helper |
Textbox |
Html.TextBoxFor |
Html.TextBox |
Checkbox |
Html.CheckBoxFor |
Html.CheckBox |
Dropdown, Combobox |
Html.DropDownListFor |
Html.DropDownList |
Hidden field |
Html.HiddenFor |
Html.Hidden |
Html text |
Html.DisplayFor |
Html.Display |
Generates Html controls based on data type of specified model property |
Html.EditorFor |
Html.Editor |
Anchor link |
|
Html.ActionLink |
TextArea |
Html.TextAreaFor |
Html.TextArea |
Radio button |
Html.RadioButtonFor |
Html.RadioButton |
Multi-select list box |
Html.ListBoxFor |
Html.ListBox |
Password textbox |
Html.PasswordFor |
Password |
Label |
Html.LabelFor |
Html.Label |
