HtmlHelper Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides support for rendering HTML form controls and performing form validation in a web page.
public class HtmlHelper
type HtmlHelper = class
Public Class HtmlHelper
- Inheritance
-
HtmlHelper
Properties
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. |
Methods
AnonymousObjectToHtmlAttributes(Object) |
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, 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. |
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) |
Returns an HTML check box control that has the specified name. |
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, IEnumerable<SelectListItem>) |
Returns an HTML drop-down list control that has the specified name and that contains the specified list items. |
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, 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. |
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>) |
Returns an HTML drop-down list control that has the specified name, 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. |
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. |
Hidden(String, Object) |
Returns an HTML hidden control that has the specified name and value. |
Hidden(String) |
Returns an HTML hidden control that has the specified name. |
Label(String, Object) |
Returns an HTML label that displays the specified text and that has the specified custom attributes. |
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. |
Label(String, String) |
Returns an HTML label that displays the specified text and that has the specified for attribute. |
Label(String) |
Returns an HTML label that displays the specified text. |
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, 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, 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, IEnumerable<SelectListItem>) |
Returns an HTML list box control that has the specified name and that contains the specified list items. |
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, 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, 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. |
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, 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) |
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, String, IEnumerable<SelectListItem>) |
Returns an HTML list box control that has the specified name, and that contains the specified list items and default item. |
ObjectToDictionary(Object) |
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, 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. |
Password(String, Object) |
Returns an HTML password control that has the specified name and value. |
Password(String) |
Returns an HTML password control that has the specified name. |
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. |
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) |
Returns an HTML radio button control that has the specified name and value. |
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, 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, 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, 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. |
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) |
Returns an HTML multi-line text input (text area) control that has the specified name and value. |
TextArea(String) |
Returns an HTML multi-line text input (text area) control that has the specified name. |
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. |
TextBox(String, Object) |
Returns an HTML text control that has the specified name and value. |
TextBox(String) |
Returns an HTML text control that has the specified name. |
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, 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. |
ValidationMessage(String, String) |
Returns an HTML span element that contains a validation error message for the specified form field. |
ValidationMessage(String) |
Returns an HTML span element that contains the first 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, 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. |
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) |
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. |