HtmlHelper Class
Represents support for rendering HTML controls in a view.
Inheritance Hierarchy
System.Object
System.Web.Mvc.HtmlHelper
System.Web.Mvc.HtmlHelper<TModel>
Namespace: System.Web.Mvc
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
Syntax
'Declaration
Public Class HtmlHelper
public class HtmlHelper
public ref class HtmlHelper
The HtmlHelper type exposes the following members.
Constructors
Name | Description | |
---|---|---|
HtmlHelper(ViewContext, IViewDataContainer) | Initializes a new instance of the HtmlHelper class by using the specified view context and view data container. | |
HtmlHelper(ViewContext, IViewDataContainer, RouteCollection) | Initializes a new instance of the HtmlHelper class by using the specified view context, view data container, and route collection. |
Top
Properties
Name | Description | |
---|---|---|
IdAttributeDotReplacement | Gets or sets the character that replaces periods in the ID attribute of an element. | |
RouteCollection | Gets or sets the collection of routes for the application. | |
ViewContext | Gets or sets the context information about the view. | |
ViewData | Gets the current view data dictionary. | |
ViewDataContainer | Gets or sets the view data container. |
Top
Methods
Name | Description | |
---|---|---|
AntiForgeryToken() | Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. | |
AntiForgeryToken(String) | Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. The field value is generated using the specified salt value. | |
AntiForgeryToken(String, String, String) | Generates a hidden form field (anti-forgery token) that is validated when the form is submitted. The field value is generated using the specified salt value, domain, and path. | |
AttributeEncode(Object) | Converts the specified attribute object to an HTML-encoded string. | |
AttributeEncode(String) | Converts the specified attribute string to an HTML-encoded string. | |
EnableClientValidation | Enables input validation that is performed by using client script in the browser. | |
Encode(Object) | Converts the value of the specified object to an HTML-encoded string. | |
Encode(String) | Converts the specified string to an HTML-encoded string. | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GenerateIdFromName(String) | Creates an HTML element ID using the specified element name. | |
GenerateIdFromName(String, String) | Creates an HTML element ID using the specified element name and a string that replaces dots in the name. | |
GenerateLink(RequestContext, RouteCollection, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>) | Generates an HTML anchor element (a element) that links to the specified action method. | |
GenerateLink(RequestContext, RouteCollection, String, String, String, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>) | Generates an HTML anchor element (a element) that links to the specified action method, and enables the user to specify the communication protocol, name of the host, and a URL fragment. | |
GenerateRouteLink(RequestContext, RouteCollection, String, String, RouteValueDictionary, IDictionary<String, Object>) | Generates an HTML anchor element (a element) that links to the specified URL route. | |
GenerateRouteLink(RequestContext, RouteCollection, String, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>) | Generates an HTML anchor element (a element) that links to the specified URL route, and enables the user to specify the communication protocol, name of the host, and a URL fragment. | |
GetFormMethodString | Returns the HTTP method that handles form input (GET or POST) as a string. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetInputTypeString | Returns the HTML input control type as a string. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
HttpMethodOverride(String) | Returns a hidden input element that identifies the override method for the specified HTTP data-transfer method that was used by the client. | |
HttpMethodOverride(HttpVerbs) | Returns a hidden input element that identifies the override method for the specified verb that represents the HTTP data-transfer method used by the client. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Extension Methods
Name | Description | |
---|---|---|
Action(String) | Overloaded. Invokes the specified child action method and returns the result as an HTML string. (Defined by ChildActionExtensions.) | |
Action(String, Object) | Overloaded. Invokes the specified child action method with the specified parameters and returns the result as an HTML string. (Defined by ChildActionExtensions.) | |
Action(String, RouteValueDictionary) | Overloaded. Invokes the specified child action method using the specified parameters and returns the result as an HTML string. (Defined by ChildActionExtensions.) | |
Action(String, String) | Overloaded. Invokes the specified child action method using the specified controller name and returns the result as an HTML string. (Defined by ChildActionExtensions.) | |
Action(String, String, Object) | Overloaded. Invokes the specified child action method using the specified parameters and controller name and returns the result as an HTML string. (Defined by ChildActionExtensions.) | |
Action(String, String, RouteValueDictionary) | Overloaded. Invokes the specified child action method using the specified parameters and controller name and returns the result as an HTML string. (Defined by ChildActionExtensions.) | |
ActionLink(String, String) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, RouteValueDictionary) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, String) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, Object, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, RouteValueDictionary, IDictionary<String, Object>) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, String, Object, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, String, RouteValueDictionary, IDictionary<String, Object>) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, String, String, String, String, Object, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
ActionLink(String, String, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
BeginForm() | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(Object) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(RouteValueDictionary) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, Object) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, RouteValueDictionary) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, FormMethod) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, Object, FormMethod) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, RouteValueDictionary, FormMethod) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, FormMethod, Object) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, FormMethod, IDictionary<String, Object>) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, Object, FormMethod, Object) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginForm(String, String, RouteValueDictionary, FormMethod, IDictionary<String, Object>) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method. (Defined by FormExtensions.) | |
BeginRouteForm(Object) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(RouteValueDictionary) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, Object) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, RouteValueDictionary) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, FormMethod) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, Object, FormMethod) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, RouteValueDictionary, FormMethod) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, FormMethod, Object) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, FormMethod, IDictionary<String, Object>) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, Object, FormMethod, Object) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
BeginRouteForm(String, RouteValueDictionary, FormMethod, IDictionary<String, Object>) | Overloaded. Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target. (Defined by FormExtensions.) | |
CheckBox(String) | Overloaded. Returns a check box input element by using the specified HTML helper and the name of the form field. (Defined by InputExtensions.) | |
CheckBox(String, Boolean) | Overloaded. Returns a check box input element by using the specified HTML helper, the name of the form field, and a value to indicate whether the check box is selected. (Defined by InputExtensions.) | |
CheckBox(String, Object) | Overloaded. Returns a check box input element by using the specified HTML helper, the name of the form field, and the HTML attributes. (Defined by InputExtensions.) | |
CheckBox(String, IDictionary<String, Object>) | Overloaded. Returns a check box input element by using the specified HTML helper, the name of the form field, and the HTML attributes. (Defined by InputExtensions.) | |
CheckBox(String, Boolean, Object) | Overloaded. Returns a check box input element by using the specified HTML helper, the name of the form field, a value that indicates whether the check box is selected, and the HTML attributes. (Defined by InputExtensions.) | |
CheckBox(String, Boolean, IDictionary<String, Object>) | Overloaded. Returns a check box input element by using the specified HTML helper, the name of the form field, a value to indicate whether the check box is selected, and the HTML attributes. (Defined by InputExtensions.) | |
Display(String) | Overloaded. Returns HTML markup for each property in the object that is represented by a string expression. (Defined by DisplayExtensions.) | |
Display(String, Object) | Overloaded. Returns HTML markup for each property in the object that is represented by a string expression, using additional view data. (Defined by DisplayExtensions.) | |
Display(String, String) | Overloaded. Returns HTML markup for each property in the object that is represented by the expression, using the specified template. (Defined by DisplayExtensions.) | |
Display(String, String, Object) | Overloaded. Returns HTML markup for each property in the object that is represented by the expression, using the specified template and additional view data. (Defined by DisplayExtensions.) | |
Display(String, String, String) | Overloaded. Returns HTML markup for each property in the object that is represented by the expression, using the specified template and an HTML field ID. (Defined by DisplayExtensions.) | |
Display(String, String, String, Object) | Overloaded. Returns HTML markup for each property in the object that is represented by the expression, using the specified template, HTML field ID, and additional view data. (Defined by DisplayExtensions.) | |
DisplayForModel() | Overloaded. Returns HTML markup for each property in the model. (Defined by DisplayExtensions.) | |
DisplayForModel(Object) | Overloaded. Returns HTML markup for each property in the model, using additional view data. (Defined by DisplayExtensions.) | |
DisplayForModel(String) | Overloaded. Returns HTML markup for each property in the model using the specified template. (Defined by DisplayExtensions.) | |
DisplayForModel(String, Object) | Overloaded. Returns HTML markup for each property in the model, using the specified template and additional view data. (Defined by DisplayExtensions.) | |
DisplayForModel(String, String) | Overloaded. Returns HTML markup for each property in the model using the specified template and HTML field ID. (Defined by DisplayExtensions.) | |
DisplayForModel(String, String, Object) | Overloaded. Returns HTML markup for each property in the model, using the specified template, an HTML field ID, and additional view data. (Defined by DisplayExtensions.) | |
DisplayText | Returns HTML markup for each property in the object that is represented by the specified expression. (Defined by DisplayTextExtensions.) | |
DropDownList(String) | Overloaded. Returns a single-selection select element using the specified HTML helper and the name of the form field. (Defined by SelectExtensions.) | |
DropDownList(String, String) | Overloaded. Returns a single-selection select element using the specified HTML helper, the name of the form field, and an option label. (Defined by SelectExtensions.) | |
DropDownList(String, IEnumerable<SelectListItem>) | Overloaded. Returns a single-selection select element using the specified HTML helper, the name of the form field, and the specified list items. (Defined by SelectExtensions.) | |
DropDownList(String, IEnumerable<SelectListItem>, Object) | Overloaded. Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HTML attributes. (Defined by SelectExtensions.) | |
DropDownList(String, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Overloaded. Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HTML attributes. (Defined by SelectExtensions.) | |
DropDownList(String, IEnumerable<SelectListItem>, String) | Overloaded. Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and an option label. (Defined by SelectExtensions.) | |
DropDownList(String, IEnumerable<SelectListItem>, String, Object) | Overloaded. Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, an option label, and the specified HTML attributes. (Defined by SelectExtensions.) | |
DropDownList(String, IEnumerable<SelectListItem>, String, IDictionary<String, Object>) | Overloaded. Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, an option label, and the specified HTML attributes. (Defined by SelectExtensions.) | |
Editor(String) | Overloaded. Returns an HTML input element for each property in the object that is represented by the expression. (Defined by EditorExtensions.) | |
Editor(String, Object) | Overloaded. Returns an HTML input element for each property in the object that is represented by the expression, using additional view data. (Defined by EditorExtensions.) | |
Editor(String, String) | Overloaded. Returns an HTML input element for each property in the object that is represented by the expression, using the specified template. (Defined by EditorExtensions.) | |
Editor(String, String, Object) | Overloaded. Returns an HTML input element for each property in the object that is represented by the expression, using the specified template and additional view data. (Defined by EditorExtensions.) | |
Editor(String, String, String) | Overloaded. Returns an HTML input element for each property in the object that is represented by the expression, using the specified template and HTML field name. (Defined by EditorExtensions.) | |
Editor(String, String, String, Object) | Overloaded. Returns an HTML input element for each property in the object that is represented by the expression, using the specified template, HTML field name, and additional view data. (Defined by EditorExtensions.) | |
EditorForModel() | Overloaded. Returns an HTML input element for each property in the model. (Defined by EditorExtensions.) | |
EditorForModel(Object) | Overloaded. Returns an HTML input element for each property in the model, using additional view data. (Defined by EditorExtensions.) | |
EditorForModel(String) | Overloaded. Returns an HTML input element for each property in the model, using the specified template. (Defined by EditorExtensions.) | |
EditorForModel(String, Object) | Overloaded. Returns an HTML input element for each property in the model, using the specified template and additional view data. (Defined by EditorExtensions.) | |
EditorForModel(String, String) | Overloaded. Returns an HTML input element for each property in the model, using the specified template name and HTML field name. (Defined by EditorExtensions.) | |
EditorForModel(String, String, Object) | Overloaded. Returns an HTML input element for each property in the model, using the template name, HTML field name, and additional view data. (Defined by EditorExtensions.) | |
EndForm | Renders the closing </form> tag to the response. (Defined by FormExtensions.) | |
Hidden(String) | Overloaded. Returns a hidden input element by using the specified HTML helper and the name of the form field. (Defined by InputExtensions.) | |
Hidden(String, Object) | Overloaded. Returns a hidden input element by using the specified HTML helper, the name of the form field, and the value. (Defined by InputExtensions.) | |
Hidden(String, Object, Object) | Overloaded. Returns a hidden input element by using the specified HTML helper, the name of the form field, the value, and the HTML attributes. (Defined by InputExtensions.) | |
Hidden(String, Object, IDictionary<String, Object>) | Overloaded. Returns a hidden input element by using the specified HTML helper, the name of the form field, the value, and the HTML attributes. (Defined by InputExtensions.) | |
Label | Returns an HTML label element and the property name of the property that is represented by the specified expression. (Defined by LabelExtensions.) | |
LabelForModel | Returns an HTML label element and the property name of the property that is represented by the model. (Defined by LabelExtensions.) | |
ListBox(String) | Overloaded. Returns a multi-select select element using the specified HTML helper and the name of the form field. (Defined by SelectExtensions.) | |
ListBox(String, IEnumerable<SelectListItem>) | Overloaded. Returns a multi-select select element using the specified HTML helper, the name of the form field, and the specified list items. (Defined by SelectExtensions.) | |
ListBox(String, IEnumerable<SelectListItem>, Object) | Overloaded. Returns a multi-select select element using the specified HTML helper, the name of the form field, and the specified list items. (Defined by SelectExtensions.) | |
ListBox(String, IEnumerable<SelectListItem>, IDictionary<String, Object>) | Overloaded. Returns a multi-select select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HMTL attributes. (Defined by SelectExtensions.) | |
Partial(String) | Overloaded. Renders the specified partial view as an HTML-encoded string. (Defined by PartialExtensions.) | |
Partial(String, ViewDataDictionary) | Overloaded. Renders the specified partial view as an HTML-encoded string. (Defined by PartialExtensions.) | |
Partial(String, Object) | Overloaded. Renders the specified partial view as an HTML-encoded string. (Defined by PartialExtensions.) | |
Partial(String, Object, ViewDataDictionary) | Overloaded. Renders the specified partial view as an HTML-encoded string. (Defined by PartialExtensions.) | |
Password(String) | Overloaded. Returns a password input element by using the specified HTML helper and the name of the form field. (Defined by InputExtensions.) | |
Password(String, Object) | Overloaded. Returns a password input element by using the specified HTML helper, the name of the form field, and the value. (Defined by InputExtensions.) | |
Password(String, Object, Object) | Overloaded. Returns a password input element by using the specified HTML helper, the name of the form field, the value, and the HTML attributes. (Defined by InputExtensions.) | |
Password(String, Object, IDictionary<String, Object>) | Overloaded. Returns a password input element by using the specified HTML helper, the name of the form field, the value, and the HTML attributes. (Defined by InputExtensions.) | |
RadioButton(String, Object) | Overloaded. Returns a radio button input element that is used to present mutually exclusive options. (Defined by InputExtensions.) | |
RadioButton(String, Object, Object) | Overloaded. Returns a radio button input element that is used to present mutually exclusive options. (Defined by InputExtensions.) | |
RadioButton(String, Object, IDictionary<String, Object>) | Overloaded. Returns a radio button input element that is used to present mutually exclusive options. (Defined by InputExtensions.) | |
RadioButton(String, Object, Boolean) | Overloaded. Returns a radio button input element that is used to present mutually exclusive options. (Defined by InputExtensions.) | |
RadioButton(String, Object, Boolean, Object) | Overloaded. Returns a radio button input element that is used to present mutually exclusive options. (Defined by InputExtensions.) | |
RadioButton(String, Object, Boolean, IDictionary<String, Object>) | Overloaded. Returns a radio button input element that is used to present mutually exclusive options. (Defined by InputExtensions.) | |
RenderAction(String) | Overloaded. Invokes the specified child action method and renders the result inline in the parent view. (Defined by ChildActionExtensions.) | |
RenderAction(String, Object) | Overloaded. Invokes the specified child action method using the specified parameters and renders the result inline in the parent view. (Defined by ChildActionExtensions.) | |
RenderAction(String, RouteValueDictionary) | Overloaded. Invokes the specified child action method using the specified parameters and renders the result inline in the parent view. (Defined by ChildActionExtensions.) | |
RenderAction(String, String) | Overloaded. Invokes the specified child action method using the specified controller name and renders the result inline in the parent view. (Defined by ChildActionExtensions.) | |
RenderAction(String, String, Object) | Overloaded. Invokes the specified child action method using the specified parameters and controller name and renders the result inline in the parent view. (Defined by ChildActionExtensions.) | |
RenderAction(String, String, RouteValueDictionary) | Overloaded. Invokes the specified child action method using the specified parameters and controller name and renders the result inline in the parent view. (Defined by ChildActionExtensions.) | |
RenderPartial(String) | Overloaded. Renders the specified partial view by using the specified HMTL helper. (Defined by RenderPartialExtensions.) | |
RenderPartial(String, ViewDataDictionary) | Overloaded. Renders the specified partial view, replacing its ViewData property with the specified ViewDataDictionary object. (Defined by RenderPartialExtensions.) | |
RenderPartial(String, Object) | Overloaded. Renders the specified partial view, passing it a copy of the current ViewDataDictionary object, but with the Model property set to the specified model. (Defined by RenderPartialExtensions.) | |
RenderPartial(String, Object, ViewDataDictionary) | Overloaded. Renders the specified partial view, replacing the partial view's ViewData property with the specified ViewDataDictionary object and setting the Model property of the view data to the specified model. (Defined by RenderPartialExtensions.) | |
RouteLink(String, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, RouteValueDictionary) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, String) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, String, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, String, RouteValueDictionary) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, Object, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, RouteValueDictionary, IDictionary<String, Object>) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, String, Object, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, String, RouteValueDictionary, IDictionary<String, Object>) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, String, String, String, String, Object, Object) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
RouteLink(String, String, String, String, String, RouteValueDictionary, IDictionary<String, Object>) | Overloaded. Returns an anchor element (a element) that contains the virtual path of the specified action. (Defined by LinkExtensions.) | |
TextArea(String) | Overloaded. Returns the specified textarea element by using the specified HTML helper and the name of the form field. (Defined by TextAreaExtensions.) | |
TextArea(String, Object) | Overloaded. Returns the specified textarea element by using the specified HTML helper and HTML attributes. (Defined by TextAreaExtensions.) | |
TextArea(String, IDictionary<String, Object>) | Overloaded. Returns the specified textarea element by using the specified HTML helper, the name of the form field, and the specified HTML attributes. (Defined by TextAreaExtensions.) | |
TextArea(String, String) | Overloaded. Returns the specified textarea element by using the specified HTML helper, the name of the form field, and the text content. (Defined by TextAreaExtensions.) | |
TextArea(String, String, Object) | Overloaded. Returns the specified textarea element by using the specified HTML helper, the name of the form field, the text content, and the specified HTML attributes. (Defined by TextAreaExtensions.) | |
TextArea(String, String, IDictionary<String, Object>) | Overloaded. Returns the specified textarea element by using the specified HTML helper, the name of the form field, the text content, and the specified HTML attributes. (Defined by TextAreaExtensions.) | |
TextArea(String, String, Int32, Int32, Object) | Overloaded. Returns the specified textarea element by using the specified HTML helper, the name of the form field, the text content, the number of rows and columns, and the specified HTML attributes. (Defined by TextAreaExtensions.) | |
TextArea(String, String, Int32, Int32, IDictionary<String, Object>) | Overloaded. Returns the specified textarea element by using the specified HTML helper, the name of the form field, the text content, the number of rows and columns, and the specified HTML attributes. (Defined by TextAreaExtensions.) | |
TextBox(String) | Overloaded. Returns a text input element by using the specified HTML helper and the name of the form field. (Defined by InputExtensions.) | |
TextBox(String, Object) | Overloaded. Returns a text input element by using the specified HTML helper, the name of the form field, and the value. (Defined by InputExtensions.) | |
TextBox(String, Object, Object) | Overloaded. Returns a text input element by using the specified HTML helper, the name of the form field, the value, and the HTML attributes. (Defined by InputExtensions.) | |
TextBox(String, Object, IDictionary<String, Object>) | Overloaded. Returns a text input element by using the specified HTML helper, the name of the form field, the value, and the HTML attributes. (Defined by InputExtensions.) | |
Validate | Retrieves the validation metadata for the specified model and applies each rule to the data field. (Defined by ValidationExtensions.) | |
ValidationMessage(String) | Overloaded. Displays a validation message if an error exists for the specified field in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationMessage(String, Object) | Overloaded. Displays a validation message if an error exists for the specified field in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationMessage(String, String) | Overloaded. Displays a validation message if an error exists for the specified field in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationMessage(String, IDictionary<String, Object>) | Overloaded. Displays a validation message if an error exists for the specified field in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationMessage(String, String, Object) | Overloaded. Displays a validation message if an error exists for the specified field in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationMessage(String, String, IDictionary<String, Object>) | Overloaded. Displays a validation message if an error exists for the specified field in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationSummary() | Overloaded. Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationSummary(Boolean) | Overloaded. Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object and optionally displays only model-level errors. (Defined by ValidationExtensions.) | |
ValidationSummary(String) | Overloaded. Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationSummary(Boolean, String) | Overloaded. Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object and optionally displays only model-level errors. (Defined by ValidationExtensions.) | |
ValidationSummary(String, Object) | Overloaded. Returns an unordered list (ul element) of validation messages in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationSummary(String, IDictionary<String, Object>) | Overloaded. Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object. (Defined by ValidationExtensions.) | |
ValidationSummary(Boolean, String, Object) | Overloaded. Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object and optionally displays only model-level errors. (Defined by ValidationExtensions.) | |
ValidationSummary(Boolean, String, IDictionary<String, Object>) | Overloaded. Returns an unordered list (ul element) of validation messages that are in the ModelStateDictionary object and optionally displays only model-level errors. (Defined by ValidationExtensions.) |
Top
Fields
Name | Description | |
---|---|---|
ValidationInputCssClassName | The name of the CSS class that is used to style an input field when a validation error occurs. | |
ValidationInputValidCssClassName | The name of the CSS class that is used to style an input field when the input is valid. | |
ValidationMessageCssClassName | The name of the CSS class that is used to style the error message when a validation error occurs. | |
ValidationMessageValidCssClassName | The name of the CSS class that is used to style the validation message when the input is valid. | |
ValidationSummaryCssClassName | The name of the CSS class that is used to style validation summary error messages. | |
ValidationSummaryValidCssClassName | The name of the CSS class that is used to style the validation summary when the input is valid. |
Top
Remarks
The HtmlHelper class provides methods that help you create HTML controls programmatically. All HtmlHelper methods generate HTML and return the result as a string.
Note
The HtmlHelper class is designed to generate UI. It should not be used in controllers or models.
Extension methods for the HtmlHelper class are in the System.Web.Mvc.Html namespace. These extensions add helper methods for creating forms, rendering HTML controls, rendering partial views, performing input validation, and more.
Helper methods and extensions are called using the Html property of the view, which is an instance of the HtmlHelper class. For example, to generate a check box in a form, you call the CheckBox method in a view using the following syntax:
<%= Html.CheckBox("OptionName") %>
Examples
The following example shows how to use the HtmlHelper class and shows how to use the methods of the InputExtensions class. The view displays a text box, a password box, some radio buttons, and some check boxes.
<h2><%= Html.Encode(ViewData("Message")) %></h2>
<br /><br />
<% Using Html.BeginForm("Input", "Home")%>
Enter your name: <%= Html.TextBox("name") %>
<br /><br />
Enter a password: <%= Html.Password("pass") %> (Not actually used.)
<br /><br />
Select your favorite color:<br />
<%= Html.RadioButton("favColor", "Blue", true) %> Blue <br />
<%= Html.RadioButton("favColor", "Purple", false)%> Purple <br />
<%= Html.RadioButton("favColor", "Red", false)%> Red <br />
<%= Html.RadioButton("favColor", "Orange", false)%> Orange <br />
<%= Html.RadioButton("favColor", "Yellow", false)%> Yellow <br />
<%= Html.RadioButton("favColor", "Brown", false)%> Brown <br />
<%= Html.RadioButton("favColor", "Green", false)%> Green
<br /><br />
<%= Html.CheckBox("technical") %> I like to read technical books.<br />
<%= Html.CheckBox("novels") %> I like to read novels.<br />
<%= Html.CheckBox("comic") %> I like to read comic books.<br />
<br /><br />
<input type="submit" value="Submit" />
<% End Using%>
<h2><%= Html.Encode(ViewData["Message"]) %></h2>
<br /><br />
<% using(Html.BeginForm("Input", "Home")) %>
<% { %>
Enter your name: <%= Html.TextBox("name") %>
<br /><br />
Enter a password: <%= Html.Password("pass") %> (Not actually used.)
<br /><br />
Select your favorite color:<br />
<%= Html.RadioButton("favColor", "Blue", true) %> Blue <br />
<%= Html.RadioButton("favColor", "Purple", false)%> Purple <br />
<%= Html.RadioButton("favColor", "Red", false)%> Red <br />
<%= Html.RadioButton("favColor", "Orange", false)%> Orange <br />
<%= Html.RadioButton("favColor", "Yellow", false)%> Yellow <br />
<%= Html.RadioButton("favColor", "Brown", false)%> Brown <br />
<%= Html.RadioButton("favColor", "Green", false)%> Green
<br /><br />
<%= Html.CheckBox("technical") %> I like to read technical books.<br />
<%= Html.CheckBox("novels") %> I like to read novels.<br />
<%= Html.CheckBox("comic") %> I like to read comic books.<br />
<br /><br />
<input type="submit" value="Submit" />
<% } %>
The following example shows a form. When the user submits the form, the Input action method processes the form data and renders a view.
Function Input(ByVal name As String, ByVal pass As String, _
ByVal favColor As String, ByVal technical As Boolean, _
ByVal novels As Boolean, _
ByVal comic As Boolean) As ActionResult
ViewData("name") = name
ViewData("favColor") = favColor
Dim bookMsg As String = ""
If (technical) Then bookMsg = "You read technical books.<br />"
If (novels) Then bookMsg = bookMsg + "You read novels.<br />"
If (comic) Then bookMsg = bookMsg + "You read comic books."
ViewData("books") = bookMsg
Return View()
End Function
public ActionResult Input(string name, string pass,
string favColor, Boolean technical, Boolean novels,
Boolean comic)
{
ViewData["name"] = name;
ViewData["favColor"] = favColor;
string bookMsg = "";
if (technical) bookMsg = "You read tehnical books.<br />";
if (novels) bookMsg += "You read novels.<br />";
if (comic) bookMsg += "You read comic books.";
ViewData["books"] = bookMsg;
return View();
}
In the following example, the view displays the data that was submitted.
<h2>HTML Input Extensions</h2>
<p>Hello, <b><%=Html.Encode(ViewData("name"))%></b></p>
<p>Your favorite color: <b><%=Html.Encode(ViewData("favColor"))%></b></p>
<p><%=ViewData("books")%></p>
<h2>HTML Input Extensions</h2>
<p>Hello, <b><%= Html.Encode(ViewData["name"])%></b></p>
<p>Your favorite color: <b><%= Html.Encode(ViewData["favColor"]) %></b></p>
<p><%= ViewData["books"] %></p>
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.