HtmlHelper Class
Provides support for rendering HTML form controls and performing form validation in a web page.
Inheritance Hierarchy
System.Object
System.Web.WebPages.Html.HtmlHelper
Namespace: System.Web.WebPages.Html
Assembly: System.Web.WebPages (in System.Web.WebPages.dll)
Syntax
'Declaration
Public Class HtmlHelper
'Usage
Dim instance As HtmlHelper
public class HtmlHelper
public ref class HtmlHelper
type HtmlHelper = class end
public class HtmlHelper
The HtmlHelper type exposes the following members.
Properties
Name | Description | |
---|---|---|
IdAttributeDotReplacement | Gets or sets the character that is used to replace the dot (.) in the id attribute of rendered form controls. | |
UnobtrusiveJavaScriptEnabled | Gets or sets a value that indicates whether the page uses unobtrusive JavaScript for Ajax functionality. | |
ValidationInputCssClassName | Gets or sets the name of the CSS class that defines the appearance of input elements when validation fails. | |
ValidationInputValidCssClassName | Gets or sets the name of the CSS class that defines the appearance of input elements when validation passes. | |
ValidationMessageCssClassName | Gets or sets the name of the CSS class that defines the appearance of validation error messages when validation fails. | |
ValidationMessageValidCssClassName | Gets or sets the name of the CSS class that defines the appearance of validation error messages when validation passes. | |
ValidationSummaryClass | Gets or sets the name of the CSS class that defines the appearance of a validation summary when validation fails. | |
ValidationSummaryValidClass | Gets or sets the name of the CSS class that defines the appearance of a validation summary when validation passes. |
Top
Methods
Name | Description | |
---|---|---|
AnonymousObjectToHtmlAttributes | Creates a dictionary of HTML attributes from the input object, translating underscores to dashes. | |
AttributeEncode(Object) | Returns an HTML-encoded string that represents the specified object by using a minimal encoding that is suitable only for HTML attributes that are enclosed in quotation marks. | |
AttributeEncode(String) | Returns an HTML-encoded string that represents the specified string by using a minimal encoding that is suitable only for HTML attributes that are enclosed in quotation marks. | |
CheckBox(String) | Returns an HTML check box control that has the specified name. | |
CheckBox(String, Boolean) | Returns an HTML check box control that has the specified name and default checked status. | |
CheckBox(String, IDictionary<String, Object>) | Returns an HTML check box control that has the specified name and custom attributes defined by an attribute dictionary. | |
CheckBox(String, Object) | Returns an HTML check box control that has the specified name and custom attributes defined by an attribute object. | |
CheckBox(String, Boolean, IDictionary<String, Object>) | Returns an HTML check box control that has the specified name, default checked status, and custom attributes defined by an attribute dictionary. | |
CheckBox(String, Boolean, Object) | Returns an HTML check box control that has the specified name, default checked status, and custom attributes defined by an attribute object. | |
DropDownList(String, IEnumerable<SelectListItem>) | Returns an HTML drop-down list control that has the specified name and that contains the specified list items. | |
DropDownList(String, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items. | |
DropDownList(String, IEnumerable<SelectListItem>, Object) | Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items. | |
DropDownList(String, String, IEnumerable<SelectListItem>) | Returns an HTML drop-down list control that has the specified name, and that contains the specified list items and default item. | |
DropDownList(String, String, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items and default item. | |
DropDownList(String, String, IEnumerable<SelectListItem>, Object) | Returns an HTML drop-down list control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items and default item. | |
DropDownList(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String, Object>) | Returns an HTML drop-down list control that has the specified name, custom attributes defined by an attribute dictionary, and default selection, and that contains the specified list items and default item. | |
DropDownList(String, String, IEnumerable<SelectListItem>, Object, Object) | Returns an HTML drop-down list control that has the specified name, custom attributes defined by an attribute object, and default selection, and that contains the specified list items and default item. | |
Encode(Object) | Returns an HTML-encoded string that represents the specified object by using a full encoding that is suitable for arbitrary HTML. | |
Encode(String) | Returns an HTML-encoded string that represents the specified string by using a full encoding that is suitable for arbitrary HTML. | |
Equals | (Inherited from Object.) | |
Finalize | (Inherited from Object.) | |
GetHashCode | (Inherited from Object.) | |
GetType | (Inherited from Object.) | |
Hidden(String) | Returns an HTML hidden control that has the specified name. | |
Hidden(String, Object) | Returns an HTML hidden control that has the specified name and value. | |
Hidden(String, Object, IDictionary<String, Object>) | Returns an HTML hidden control that has the specified name, value, and custom attributes defined by an attribute dictionary. | |
Hidden(String, Object, Object) | Returns an HTML hidden control that has the specified name, value, and custom attributes defined by an attribute object. | |
Label(String) | Returns an HTML label that displays the specified text. | |
Label(String, Object) | Returns an HTML label that displays the specified text and that has the specified custom attributes. | |
Label(String, String) | Returns an HTML label that displays the specified text and that has the specified for attribute. | |
Label(String, String, IDictionary<String, Object>) | Returns an HTML label that displays the specified text, and that has the specified for attribute and custom attributes defined by an attribute dictionary. | |
Label(String, String, Object) | Returns an HTML label that displays the specified text, and that has the specified for attribute and custom attributes defined by an attribute object. | |
ListBox(String, IEnumerable<SelectListItem>) | Returns an HTML list box control that has the specified name and that contains the specified list items. | |
ListBox(String, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items. | |
ListBox(String, IEnumerable<SelectListItem>, Object) | Returns an HTML list box control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items. | |
ListBox(String, String, IEnumerable<SelectListItem>) | Returns an HTML list box control that has the specified name, and that contains the specified list items and default item. | |
ListBox(String, String, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items and default item. | |
ListBox(String, String, IEnumerable<SelectListItem>, Object) | Returns an HTML list box control that has the specified name and custom attributes defined by an attribute object, and that contains the specified list items and default item. | |
ListBox(String, IEnumerable<SelectListItem>, Object, Int32, Boolean) | Returns an HTML list box control that has the specified name, size, list items, and default selections, and that specifies whether multiple selections are enabled. | |
ListBox(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String, Object>) | Returns an HTML list box control that has the specified name and custom attributes defined by an attribute dictionary, and that contains the specified list items, default item, and selections. | |
ListBox(String, String, IEnumerable<SelectListItem>, Object, Object) | Returns an HTML list box control that has the specified name, items, default item, and custom attributes defined by an attribute object, and selections. | |
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean) | Returns an HTML list box control that has the specified name, size, items, default item, and selections, and that specifies whether multiple selections are enabled. | |
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, IDictionary<String, Object>) | Returns an HTML list box control that has the specified name, size, custom attributes defined by an attribute dictionary, items, default item, and selections, and that specifies whether multiple selections are enabled. | |
ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, Object) | Returns an HTML list box control that has the specified name, size, custom attributes defined by an attribute object, items, default item, and selections, and that specifies whether multiple selections are enabled. | |
MemberwiseClone | (Inherited from Object.) | |
ObjectToDictionary | Creates a dictionary from an object, by adding each public instance property as a key with its associated value to the dictionary. It will expose public properties from derived types as well. This is typically used with objects of an anonymous type. | |
Password(String) | Returns an HTML password control that has the specified name. | |
Password(String, Object) | Returns an HTML password control that has the specified name and value. | |
Password(String, Object, IDictionary<String, Object>) | Returns an HTML password control that has the specified name, value, and custom attributes defined by an attribute dictionary. | |
Password(String, Object, Object) | Returns an HTML password control that has the specified name, value, and custom attributes defined by an attribute object. | |
RadioButton(String, Object) | Returns an HTML radio button control that has the specified name and value. | |
RadioButton(String, Object, Boolean) | Returns an HTML radio button control that has the specified name, value, and default selected status. | |
RadioButton(String, Object, IDictionary<String, Object>) | Returns an HTML radio button control that has the specified name, value, and custom attributes defined by an attribute dictionary. | |
RadioButton(String, Object, Object) | Returns an HTML radio button control that has the specified name, value, and custom attributes defined by an attribute object. | |
RadioButton(String, Object, Boolean, IDictionary<String, Object>) | Returns an HTML radio button control that has the specified name, value, default selected status, and custom attributes defined by an attribute dictionary. | |
RadioButton(String, Object, Boolean, Object) | Returns an HTML radio button control that has the specified name, value, default selected status, and custom attributes defined by an attribute object. | |
Raw(Object) | Wraps HTML markup in an HtmlString instance so that it is interpreted as HTML markup. | |
Raw(String) | Wraps HTML markup in an HtmlString instance so that it is interpreted as HTML markup. | |
TextArea(String) | Returns an HTML multi-line text input (text area) control that has the specified name. | |
TextArea(String, IDictionary<String, Object>) | Returns an HTML multi-line text input (text area) control that has the specified name and custom attributes defined by an attribute dictionary. | |
TextArea(String, Object) | Returns an HTML multi-line text input (text area) control that has the specified name and custom attributes defined by an attribute object. | |
TextArea(String, String) | Returns an HTML multi-line text input (text area) control that has the specified name and value. | |
TextArea(String, String, IDictionary<String, Object>) | Returns an HTML multi-line text input (text area) control that has the specified name, value, and custom attributes defined by an attribute dictionary. | |
TextArea(String, String, Object) | Returns an HTML multi-line text input (text area) control that has the specified name, value, and custom attributes defined by an attribute object. | |
TextArea(String, String, Int32, Int32, IDictionary<String, Object>) | Returns an HTML multi-line text input (text area) control that has the specified name, value, row attribute, col attribute, and custom attributes defined by an attribute dictionary. | |
TextArea(String, String, Int32, Int32, Object) | Returns an HTML multi-line text input (text area) control that has the specified name, value, row attribute, col attribute, and custom attributes defined by an attribute object. | |
TextBox(String) | Returns an HTML text control that has the specified name. | |
TextBox(String, Object) | Returns an HTML text control that has the specified name and value. | |
TextBox(String, Object, IDictionary<String, Object>) | Returns an HTML text control that has the specified name, value, and custom attributes defined by an attribute dictionary. | |
TextBox(String, Object, Object) | Returns an HTML text control that has the specified name, value, and custom attributes defined by an attribute object. | |
ToString | (Inherited from Object.) | |
ValidationMessage(String) | Returns an HTML span element that contains the first validation error message for the specified form field. | |
ValidationMessage(String, IDictionary<String, Object>) | Returns an HTML span element that has the specified custom attributes defined by an attribute dictionary, and that contains the first validation error message for the specified form field. | |
ValidationMessage(String, Object) | Returns an HTML span element that has the specified custom attributes defined by an attribute object, and that contains the first validation error message for the specified form field. | |
ValidationMessage(String, String) | Returns an HTML span element that contains a validation error message for the specified form field. | |
ValidationMessage(String, String, IDictionary<String, Object>) | Returns an HTML span element that has the specified custom attributes defined by an attribute dictionary, and that contains a validation error message for the specified form field. | |
ValidationMessage(String, String, Object) | Returns an HTML span element that has the specified custom attributes defined by an attribute object, and that contains a validation error message for the specified form field. | |
ValidationSummary() | Returns an HTML div element that contains an unordered list of all validation error messages from the model-state dictionary. | |
ValidationSummary(Boolean) | Returns an HTML div element that contains an unordered list of validation error message from the model-state dictionary, optionally excluding field-level errors. | |
ValidationSummary(IDictionary<String, Object>) | Returns an HTML div element that has the specified custom attributes defined by an attribute dictionary, and that contains an unordered list of all validation error messages that are in the model-state dictionary. | |
ValidationSummary(Object) | Returns an HTML div element that has the specified custom attributes defined by an attribute object, and that contains an unordered list of all validation error messages that are in the model-state dictionary. | |
ValidationSummary(String) | Returns an HTML div element that contains a summary message and an unordered list of all validation error messages that are in the model-state dictionary. | |
ValidationSummary(String, IDictionary<String, Object>) | Returns an HTML div element that has the specified custom attributes defined by an attribute dictionary, and that contains a summary message and an unordered list of all validation error message from the model-state dictionary. | |
ValidationSummary(String, Object) | Returns an HTML div element that has the specified custom attributes defined by an attribute object, and that contains a summary message and an unordered list of all validation error message from the model-state dictionary. | |
ValidationSummary(String, Boolean, IDictionary<String, Object>) | Returns an HTML div element that has the specified custom attributes defined by an attribute dictionary, and that contains a summary message and an unordered list of validation error message from the model-state dictionary, optionally excluding field-level errors. | |
ValidationSummary(String, Boolean, Object) | Returns an HTML div element that has the specified custom attributes defined by an attribute object, and that contains a summary message and an unordered list of validation error message from the model-state dictionary, optionally excluding field-level errors. |
Top
Remarks
The HtmlHelper class lets you render HTML form elements, perform validation, and display validation messages for those elements. To render an HTML form element in the body of a web page, you call the method for that element and pass a value for its name attribute. For example, to create an input element that renders a text box, you can use @Html.TextBox("CustomerID"). This adds markup to the rendered page that resembles the following example:
<input id="CustomerID" name="CustomerID" type="text" value="" />
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.