IHtmlGenerator Interface

Summary

Contract for a service supporting [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) and <c>ITagHelper</c> implementations.

Syntax

public interface IHtmlGenerator

GitHub

View on GitHub

interface Microsoft.AspNet.Mvc.Rendering.IHtmlGenerator

Properties

IdAttributeDotReplacement()
Return type:System.String
string IdAttributeDotReplacement { get; }

Methods

Encode(System.Object)
Arguments:
  • value (System.Object) –
Return type:

System.String

string Encode(object value)
Encode(System.String)
Arguments:
  • value (System.String) –
Return type:

System.String

string Encode(string value)
FormatValue(System.Object, System.String)
Arguments:
  • value (System.Object) –
  • format (System.String) –
Return type:

System.String

string FormatValue(object value, string format)
Arguments:
  • linkText (System.String) –
  • actionName (System.String) –
  • controllerName (System.String) –
  • protocol (System.String) –
  • hostname (System.String) –
  • fragment (System.String) –
  • routeValues (System.Object) –
  • htmlAttributes (System.Object) –
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateActionLink(string linkText, string actionName, string controllerName, string protocol, string hostname, string fragment, object routeValues, object htmlAttributes)
GenerateAntiForgery(Microsoft.AspNet.Mvc.ViewContext)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateAntiForgery(ViewContext viewContext)
GenerateCheckBox(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Nullable<System.Boolean>, System.Object)

Generate a &lt;input type=”checkbox”.../&gt; element.

Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) – The [Microsoft.AspNet.Mvc.ViewContext](Microsoft.AspNet.Mvc.ViewContext.yml) instance for the current scope.
  • modelExplorer (Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer) – The [Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer]() for the model.
  • expression (System.String) – The model expression.
  • isChecked (System.Nullable{System.Boolean}) – The initial state of the checkbox element.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

Returns:

A [Microsoft.AspNet.Mvc.Rendering.TagBuilder](Microsoft.AspNet.Mvc.Rendering.TagBuilder.yml) instance for the &lt;input type=”checkbox”.../&gt; element.

TagBuilder GenerateCheckBox(ViewContext viewContext, ModelExplorer modelExplorer, string expression, bool ? isChecked, object htmlAttributes)
GenerateForm(Microsoft.AspNet.Mvc.ViewContext, System.String, System.String, System.Object, System.String, System.Object)

Generate a &lt;form&gt; element. When the user submits the form, the action with name

<paramref name=”actionName” /> will process the request.

Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) – A [Microsoft.AspNet.Mvc.ViewContext](Microsoft.AspNet.Mvc.ViewContext.yml) instance for the current scope.
  • actionName (System.String) – The name of the action method.
  • controllerName (System.String) – The name of the controller.
  • routeValues (System.Object) – An [System.Object]() that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the [System.Object](). This [System.Object]() is typically created using [System.Object]() initializer syntax. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the route parameters.
  • method (System.String) – The HTTP method for processing the form, either GET or POST.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

Returns:

A [Microsoft.AspNet.Mvc.Rendering.TagBuilder](Microsoft.AspNet.Mvc.Rendering.TagBuilder.yml) instance for the &lt;/form&gt; element.

TagBuilder GenerateForm(ViewContext viewContext, string actionName, string controllerName, object routeValues, string method, object htmlAttributes)
GenerateHidden(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Object, System.Boolean, System.Object)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateHidden(ViewContext viewContext, ModelExplorer modelExplorer, string expression, object value, bool useViewData, object htmlAttributes)
GenerateHiddenForCheckbox(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String)

Generate an additional &lt;input type=”hidden”.../&gt; for checkboxes. This addresses scenarios where unchecked checkboxes are not sent in the request. Sending a hidden input makes it possible to know that the checkbox was present on the page when the request was submitted.

Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateHiddenForCheckbox(ViewContext viewContext, ModelExplorer modelExplorer, string expression)
GenerateLabel(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.String, System.Object)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateLabel(ViewContext viewContext, ModelExplorer modelExplorer, string expression, string labelText, object htmlAttributes)
GeneratePassword(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Object, System.Object)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GeneratePassword(ViewContext viewContext, ModelExplorer modelExplorer, string expression, object value, object htmlAttributes)
GenerateRadioButton(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Object, System.Nullable<System.Boolean>, System.Object)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateRadioButton(ViewContext viewContext, ModelExplorer modelExplorer, string expression, object value, bool ? isChecked, object htmlAttributes)
GenerateRouteForm(Microsoft.AspNet.Mvc.ViewContext, System.String, System.Object, System.String, System.Object)

Generate a &lt;form&gt; element. The route with name <paramref name=”routeName” /> generates the &lt;form&gt;’s <c>action</c> attribute value.

Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) – A [Microsoft.AspNet.Mvc.ViewContext](Microsoft.AspNet.Mvc.ViewContext.yml) instance for the current scope.
  • routeName (System.String) – The name of the route.
  • routeValues (System.Object) – An [System.Object]() that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the [System.Object](). This [System.Object]() is typically created using [System.Object]() initializer syntax. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the route parameters.
  • method (System.String) – The HTTP method for processing the form, either GET or POST.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

Returns:

A [Microsoft.AspNet.Mvc.Rendering.TagBuilder](Microsoft.AspNet.Mvc.Rendering.TagBuilder.yml) instance for the &lt;/form&gt; element.

TagBuilder GenerateRouteForm(ViewContext viewContext, string routeName, object routeValues, string method, object htmlAttributes)
Arguments:
  • linkText (System.String) –
  • routeName (System.String) –
  • protocol (System.String) –
  • hostName (System.String) –
  • fragment (System.String) –
  • routeValues (System.Object) –
  • htmlAttributes (System.Object) –
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateRouteLink(string linkText, string routeName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes)
GenerateSelect(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>, System.Boolean, System.Object)

Generate a &lt;select&gt; element for the <paramref name=”expression” />.

Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) – A [Microsoft.AspNet.Mvc.ViewContext](Microsoft.AspNet.Mvc.ViewContext.yml) instance for the current scope.
  • modelExplorer (Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer) – [Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer]() for the <paramref name=”expression” />. If <c>null</c>, determines validation attributes using <paramref name=”viewContext” /> and the <paramref name=”expression” />.
  • optionLabel (System.String) – Optional text for a default empty &lt;option&gt; element.
  • expression (System.String) – Expression name, relative to the current model.
  • selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) objects used to populate the &lt;select&gt; element with &lt;optgroup&gt; and &lt;option&gt; elements. If <c>null</c>, finds this collection at <c>ViewContext.ViewData[expression]</c>.
  • allowMultiple (System.Boolean) – If <c>true</c>, includes a <c>multiple</c> attribute in the generated HTML. Otherwise generates a single-selection &lt;select&gt; element.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the &lt;select&gt; element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.TagBuilder](Microsoft.AspNet.Mvc.Rendering.TagBuilder.yml) describing the &lt;select&gt; element.

TagBuilder GenerateSelect(ViewContext viewContext, ModelExplorer modelExplorer, string optionLabel, string expression, IEnumerable<SelectListItem> selectList, bool allowMultiple, object htmlAttributes)
GenerateSelect(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>, System.Collections.Generic.IReadOnlyCollection<System.String>, System.Boolean, System.Object)

Generate a &lt;select&gt; element for the <paramref name=”expression” />.

Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) – A [Microsoft.AspNet.Mvc.ViewContext](Microsoft.AspNet.Mvc.ViewContext.yml) instance for the current scope.
  • modelExplorer (Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer) – [Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer]() for the <paramref name=”expression” />. If <c>null</c>, determines validation attributes using <paramref name=”viewContext” /> and the <paramref name=”expression” />.
  • optionLabel (System.String) – Optional text for a default empty &lt;option&gt; element.
  • expression (System.String) – Expression name, relative to the current model.
  • selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) objects used to populate the &lt;select&gt; element with &lt;optgroup&gt; and &lt;option&gt; elements. If <c>null</c>, finds this collection at <c>ViewContext.ViewData[expression]</c>.
  • currentValues (System.Collections.Generic.IReadOnlyCollection{System.String}) – An [System.Collections.Generic.IReadOnlyCollection`1]() containing values for &lt;option&gt; elements to select. If <c>null</c>, selects &lt;option&gt; elements based on [Microsoft.AspNet.Mvc.Rendering.SelectListItem.Selected](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) values in <paramref name=”selectList” />.
  • allowMultiple (System.Boolean) – If <c>true</c>, includes a <c>multiple</c> attribute in the generated HTML. Otherwise generates a single-selection &lt;select&gt; element.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the &lt;select&gt; element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.TagBuilder](Microsoft.AspNet.Mvc.Rendering.TagBuilder.yml) describing the &lt;select&gt; element.

TagBuilder GenerateSelect(ViewContext viewContext, ModelExplorer modelExplorer, string optionLabel, string expression, IEnumerable<SelectListItem> selectList, IReadOnlyCollection<string> currentValues, bool allowMultiple, object htmlAttributes)
GenerateTextArea(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Int32, System.Int32, System.Object)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateTextArea(ViewContext viewContext, ModelExplorer modelExplorer, string expression, int rows, int columns, object htmlAttributes)
GenerateTextBox(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Object, System.String, System.Object)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateTextBox(ViewContext viewContext, ModelExplorer modelExplorer, string expression, object value, string format, object htmlAttributes)
GenerateValidationMessage(Microsoft.AspNet.Mvc.ViewContext, System.String, System.String, System.String, System.Object)
Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) –
  • expression (System.String) –
  • message (System.String) –
  • tag (System.String) –
  • htmlAttributes (System.Object) –
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateValidationMessage(ViewContext viewContext, string expression, string message, string tag, object htmlAttributes)
GenerateValidationSummary(Microsoft.AspNet.Mvc.ViewContext, System.Boolean, System.String, System.String, System.Object)
Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) –
  • excludePropertyErrors (System.Boolean) –
  • message (System.String) –
  • headerTag (System.String) –
  • htmlAttributes (System.Object) –
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

TagBuilder GenerateValidationSummary(ViewContext viewContext, bool excludePropertyErrors, string message, string headerTag, object htmlAttributes)
GetClientValidationRules(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String)
Arguments:
Return type:

System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.ModelBinding.Validation.ModelClientValidationRule}

IEnumerable<ModelClientValidationRule> GetClientValidationRules(ViewContext viewContext, ModelExplorer modelExplorer, string expression)
GetCurrentValues(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Boolean)

Gets the collection of current values for the given <paramref name=”expression” />.

Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) – A [Microsoft.AspNet.Mvc.ViewContext](Microsoft.AspNet.Mvc.ViewContext.yml) instance for the current scope.
  • modelExplorer (Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer) – [Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer]() for the <paramref name=”expression” />. If <c>null</c>, calculates the <paramref name=”expression” /> result using [Microsoft.AspNet.Mvc.ViewDataDictionary.Eval(System.String)](Microsoft.AspNet.Mvc.ViewDataDictionary.yml).
  • expression (System.String) – Expression name, relative to the current model.
  • allowMultiple (System.Boolean) – If <c>true</c>, require a collection <paramref name=”expression” /> result. Otherwise, treat result as a single value.
Return type:

System.Collections.Generic.IReadOnlyCollection{System.String}

Returns:

<para> <c>null</c> if no <paramref name=”expression” /> result is found. Otherwise an <see cref=”T:System.Collections.Generic.IReadOnlyCollection`1” /> containing current values for the given <paramref name=”expression” />. </para> <para> Converts the <paramref name=”expression” /> result to a <see cref=”T:System.String” />. If that result is an <see cref=”T:System.Collections.IEnumerable” /> type, instead converts each item in the collection and returns them separately. </para> <para> If the <paramref name=”expression” /> result or the element type is an <see cref=”T:System.Enum” />, returns a <see cref=”T:System.String” /> containing the integer representation of the <see cref=”T:System.Enum” /> value as well as all <see cref=”T:System.Enum” /> names for that value. Otherwise returns the default <see cref=”T:System.String” /> conversion of the value. </para>

IReadOnlyCollection<string> GetCurrentValues(ViewContext viewContext, ModelExplorer modelExplorer, string expression, bool allowMultiple)