Built-in HTML Helpers in ASP.NET MVC

HTML Helpers

The ASP.NET MVC framework supplies a few HTML helpers out of the box, including CheckBox, ActionLink, and RenderPartial. An HTML helper method has no view state, no postbacks, and no page life cycle and events. HTML helpers are simple HTML factories. Technically speaking, an HTML helper is an extension method defined on a system class – The HtmlHelper class that outputs an HTML string based on the provided input data. Internally an HTML helper simply accumulates text into a StringBuilder object.

List of Built-in HTML Helpers

BeginForm, BeginRouteForm: It returns an internal object that represents an HTML form that the system uses to render the tag.

EndForm: It is a void method which closes the pending tag.

CheckBox, CheckBoxFor: It returns the HTML string for a check box input element.

Hidden, HiddenFor: It returns the HTML string for a hidden input element.

Password, PasswordFor: It returns the HTML string for a password input element.

RadioButton, RadioButtonFor: It returns the HTML string for a radio button input element

TextBox, TextBoxFor: It returns the HTML string for a text input element

Label, LabelFor: It returns the HTML string for an HTML label element

ActionLink, RouteLink: It returns the HTML string for an HTML link

DropDownList, DropDownListFor: It returns the HTML string for a drop-down list

ListBox, ListBoxFor: It returns the HTML string for a list box

TextArea, TextAreaFor: It returns the HTML string for a text area

Partial: It returns the HTML string incorporated in the specified user control

RenderPartial: It writes the HTML string incorporated in the specified user control to the output stream.

ValidationMessage, ValidationMessageFor: It returns the HTML string for a validation message

ValidationSummary: It returns the HTML string for a validation summary message.

HtmlHelper class:

The HtmlHelper class provides several public methods that are of little use from within a view, but it also has several useful native methods.

AntiForgeryToken: It returns the HTML string for a hidden input field stored with the anti-forgery token.

AttributeEncode: It encodes the value of the specified attribute using the rules of HTML encoding

EnableUnobtrusiveJavaScript: It sets the internal flag that enables helpers to generate JavaScript code unobtrusively.

EnableClientValidation: It sets the internal flag that enables helpers to generate code for clientside validation.

Encode: Encodes the specified value using the rules of HTML encoding

HttpMethodOverride: It returns the HTML string for a hidden input field used to override the effective HTTP verb to indicate that a PUT or DELETE operation was requested.

Raw: It returns the raw HTML string without encoding.