HtmlHelper HtmlHelper HtmlHelper Class

Definition

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
HtmlHelperHtmlHelperHtmlHelper

Properties

IdAttributeDotReplacement IdAttributeDotReplacement IdAttributeDotReplacement

Gets or sets the character that is used to replace the dot (.) in the id attribute of rendered form controls.

UnobtrusiveJavaScriptEnabled UnobtrusiveJavaScriptEnabled UnobtrusiveJavaScriptEnabled

Gets or sets a value that indicates whether the page uses unobtrusive JavaScript for Ajax functionality.

ValidationInputCssClassName ValidationInputCssClassName ValidationInputCssClassName

Gets or sets the name of the CSS class that defines the appearance of input elements when validation fails.

ValidationInputValidCssClassName ValidationInputValidCssClassName ValidationInputValidCssClassName

Gets or sets the name of the CSS class that defines the appearance of input elements when validation passes.

ValidationMessageCssClassName ValidationMessageCssClassName ValidationMessageCssClassName

Gets or sets the name of the CSS class that defines the appearance of validation error messages when validation fails.

ValidationMessageValidCssClassName ValidationMessageValidCssClassName ValidationMessageValidCssClassName

Gets or sets the name of the CSS class that defines the appearance of validation error messages when validation passes.

ValidationSummaryClass ValidationSummaryClass ValidationSummaryClass

Gets or sets the name of the CSS class that defines the appearance of a validation summary when validation fails.

ValidationSummaryValidClass ValidationSummaryValidClass ValidationSummaryValidClass

Gets or sets the name of the CSS class that defines the appearance of a validation summary when validation passes.

Methods

AnonymousObjectToHtmlAttributes(Object) AnonymousObjectToHtmlAttributes(Object) AnonymousObjectToHtmlAttributes(Object)

Creates a dictionary of HTML attributes from the input object, translating underscores to dashes.

AttributeEncode(Object) AttributeEncode(Object) 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) AttributeEncode(String) 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) CheckBox(String) CheckBox(String)

Returns an HTML check box control that has the specified name.

CheckBox(String, Boolean) CheckBox(String, Boolean) CheckBox(String, Boolean)

Returns an HTML check box control that has the specified name and default checked status.

CheckBox(String, IDictionary<String,Object>) CheckBox(String, IDictionary<String,Object>) 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) CheckBox(String, Object) 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>) CheckBox(String, Boolean, IDictionary<String,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) CheckBox(String, Boolean, Object) 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, String, IEnumerable<SelectListItem>, Object, Object) DropDownList(String, String, IEnumerable<SelectListItem>, Object, Object) 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, IDictionary<String,Object>) DropDownList(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String,Object>) 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) DropDownList(String, String, IEnumerable<SelectListItem>, Object) 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>, IDictionary<String,Object>) DropDownList(String, String, IEnumerable<SelectListItem>, IDictionary<String,Object>) 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, IEnumerable<SelectListItem>) DropDownList(String, IEnumerable<SelectListItem>) 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>, Object) DropDownList(String, IEnumerable<SelectListItem>, Object) 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>, IDictionary<String,Object>) DropDownList(String, IEnumerable<SelectListItem>, IDictionary<String,Object>) 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, String, IEnumerable<SelectListItem>) DropDownList(String, String, IEnumerable<SelectListItem>) 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(String) Encode(String) Encode(String)

Returns an HTML-encoded string that represents the specified string by using a full encoding that is suitable for arbitrary HTML.

Encode(Object) Encode(Object) Encode(Object)

Returns an HTML-encoded string that represents the specified object by using a full encoding that is suitable for arbitrary HTML.

Hidden(String, Object, Object) Hidden(String, Object, Object) 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, IDictionary<String,Object>) Hidden(String, Object, IDictionary<String,Object>) 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) Hidden(String) Hidden(String)

Returns an HTML hidden control that has the specified name.

Hidden(String, Object) Hidden(String, Object) Hidden(String, Object)

Returns an HTML hidden control that has the specified name and value.

Label(String) Label(String) Label(String)

Returns an HTML label that displays the specified text.

Label(String, Object) Label(String, Object) Label(String, Object)

Returns an HTML label that displays the specified text and that has the specified custom attributes.

Label(String, String) Label(String, String) 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>) Label(String, String, IDictionary<String,Object>) 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) Label(String, String, Object) 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, String, IEnumerable<SelectListItem>) ListBox(String, String, IEnumerable<SelectListItem>) 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>, Object, Int32, Boolean, IDictionary<String,Object>) ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, IDictionary<String,Object>) 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) ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean) 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) ListBox(String, String, IEnumerable<SelectListItem>, Object, Object) 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, IDictionary<String,Object>) ListBox(String, String, IEnumerable<SelectListItem>, Object, IDictionary<String,Object>) 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, IEnumerable<SelectListItem>, Object, Int32, Boolean) ListBox(String, IEnumerable<SelectListItem>, Object, Int32, Boolean) 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) ListBox(String, IEnumerable<SelectListItem>, Object) 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>, IDictionary<String,Object>) ListBox(String, String, IEnumerable<SelectListItem>, IDictionary<String,Object>) 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, Int32, Boolean, Object) ListBox(String, String, IEnumerable<SelectListItem>, Object, Int32, Boolean, Object) 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, IEnumerable<SelectListItem>, IDictionary<String,Object>) ListBox(String, IEnumerable<SelectListItem>, IDictionary<String,Object>) 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>) ListBox(String, IEnumerable<SelectListItem>) 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>, Object) ListBox(String, String, IEnumerable<SelectListItem>, Object) 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.

ObjectToDictionary(Object) ObjectToDictionary(Object) 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, Object) Password(String, Object, Object) 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, IDictionary<String,Object>) Password(String, Object, IDictionary<String,Object>) 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) Password(String, Object) Password(String, Object)

Returns an HTML password control that has the specified name and value.

Password(String) Password(String) Password(String)

Returns an HTML password control that has the specified name.

RadioButton(String, Object) RadioButton(String, Object) RadioButton(String, Object)

Returns an HTML radio button control that has the specified name and value.

RadioButton(String, Object, Boolean) RadioButton(String, Object, Boolean) 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>) RadioButton(String, Object, IDictionary<String,Object>) 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) RadioButton(String, Object, Object) 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>) RadioButton(String, Object, Boolean, IDictionary<String,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) RadioButton(String, Object, Boolean, Object) 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) Raw(Object) Raw(Object)

Wraps HTML markup in an HtmlString instance so that it is interpreted as HTML markup.

Raw(String) Raw(String) Raw(String)

Wraps HTML markup in an HtmlString instance so that it is interpreted as HTML markup.

TextArea(String, String, Int32, Int32, Object) TextArea(String, String, Int32, Int32, Object) 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, Int32, Int32, IDictionary<String,Object>) TextArea(String, String, Int32, Int32, IDictionary<String,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, Object) TextArea(String, String, 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, IDictionary<String,Object>) TextArea(String, String, IDictionary<String,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, IDictionary<String,Object>) TextArea(String, IDictionary<String,Object>) 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) TextArea(String, Object) 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) TextArea(String) TextArea(String)

Returns an HTML multi-line text input (text area) control that has the specified name.

TextArea(String, String) TextArea(String, String) TextArea(String, String)

Returns an HTML multi-line text input (text area) control that has the specified name and value.

TextBox(String, Object, IDictionary<String,Object>) TextBox(String, Object, IDictionary<String,Object>) 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) TextBox(String) TextBox(String)

Returns an HTML text control that has the specified name.

TextBox(String, Object) TextBox(String, Object) TextBox(String, Object)

Returns an HTML text control that has the specified name and value.

TextBox(String, Object, Object) TextBox(String, Object, Object) TextBox(String, Object, Object)

Returns an HTML text control that has the specified name, value, and custom attributes defined by an attribute object.

ValidationMessage(String) ValidationMessage(String) ValidationMessage(String)

Returns an HTML span element that contains the first validation error message for the specified form field.

ValidationMessage(String, IDictionary<String,Object>) ValidationMessage(String, IDictionary<String,Object>) 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) ValidationMessage(String, Object) 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) ValidationMessage(String, String) 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>) ValidationMessage(String, String, IDictionary<String,Object>) 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) ValidationMessage(String, String, Object) 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(String, Boolean, Object) ValidationSummary(String, Boolean, Object) 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, Boolean, IDictionary<String,Object>) ValidationSummary(String, Boolean, IDictionary<String,Object>) 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, Object) ValidationSummary(String, Object) 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, IDictionary<String,Object>) ValidationSummary(String, IDictionary<String,Object>) 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() ValidationSummary() ValidationSummary()

Returns an HTML div element that contains an unordered list of all validation error messages from the model-state dictionary.

ValidationSummary(Object) ValidationSummary(Object) 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(IDictionary<String,Object>) ValidationSummary(IDictionary<String,Object>) 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(Boolean) ValidationSummary(Boolean) 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(String) ValidationSummary(String) 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.

Applies to