DefaultHtmlGenerator Class

Syntax

public class DefaultHtmlGenerator : IHtmlGenerator

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.Rendering.DefaultHtmlGenerator

Constructors

DefaultHtmlGenerator(Microsoft.AspNet.Mvc.AntiForgery, IOptions<Microsoft.AspNet.Mvc.MvcViewOptions>, Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider, Microsoft.AspNet.Mvc.IUrlHelper, IHtmlEncoder)

Initializes a new instance of the [Microsoft.AspNet.Mvc.Rendering.DefaultHtmlGenerator](Microsoft.AspNet.Mvc.Rendering.DefaultHtmlGenerator.yml) class.

Arguments:
  • antiForgery (Microsoft.AspNet.Mvc.AntiForgery) – The [Microsoft.AspNet.Mvc.AntiForgery](Microsoft.AspNet.Mvc.AntiForgery.yml) instance which is used to generate anti-forgery tokens.
  • optionsAccessor (IOptions{Microsoft.AspNet.Mvc.MvcViewOptions}) – The accessor for [Microsoft.AspNet.Mvc.MvcOptions]().
  • metadataProvider (Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider) – The [Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider]().
  • urlHelper (Microsoft.AspNet.Mvc.IUrlHelper) – The [Microsoft.AspNet.Mvc.IUrlHelper]().
  • htmlEncoder (IHtmlEncoder) – The @!:IHtmlEncoder-.
public DefaultHtmlGenerator(AntiForgery antiForgery, IOptions<MvcViewOptions> optionsAccessor, IModelMetadataProvider metadataProvider, IUrlHelper urlHelper, IHtmlEncoder htmlEncoder)

Properties

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

Methods

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

System.String

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

System.String

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

System.String

public 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

public virtual 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

public virtual TagBuilder GenerateAntiForgery(ViewContext viewContext)
GenerateCheckBox(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Nullable<System.Boolean>, System.Object)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

public virtual 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)
Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) –
  • actionName (System.String) –
  • controllerName (System.String) –
  • routeValues (System.Object) –
  • method (System.String) –
  • htmlAttributes (System.Object) –
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

public virtual TagBuilder GenerateForm(ViewContext viewContext, string actionName, string controllerName, object routeValues, string method, object htmlAttributes)
GenerateFormCore(Microsoft.AspNet.Mvc.ViewContext, System.String, System.String, System.Object)

Generate a &lt;form&gt; element.

Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) – A [Microsoft.AspNet.Mvc.ViewContext](Microsoft.AspNet.Mvc.ViewContext.yml) instance for the current scope.
  • action (System.String) – The URL where the form-data should be submitted.
  • 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.

protected virtual TagBuilder GenerateFormCore(ViewContext viewContext, string action, 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

public virtual 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)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

public virtual TagBuilder GenerateHiddenForCheckbox(ViewContext viewContext, ModelExplorer modelExplorer, string expression)
GenerateInput(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.Rendering.InputType, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.Object, System.Boolean, System.Boolean, System.Boolean, System.Boolean, System.String, System.Collections.Generic.IDictionary<System.String, System.Object>)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

protected virtual TagBuilder GenerateInput(ViewContext viewContext, InputType inputType, ModelExplorer modelExplorer, string expression, object value, bool useViewData, bool isChecked, bool setId, bool isExplicitValue, string format, IDictionary<string, object> htmlAttributes)
GenerateLabel(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String, System.String, System.Object)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

public virtual TagBuilder GenerateLabel(ViewContext viewContext, ModelExplorer modelExplorer, string expression, string labelText, object htmlAttributes)
Arguments:
  • linkText (System.String) –
  • url (System.String) –
  • htmlAttributes (System.Object) –
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

protected virtual TagBuilder GenerateLink(string linkText, string url, 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

public virtual 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

public virtual 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)
Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) –
  • routeName (System.String) –
  • routeValues (System.Object) –
  • method (System.String) –
  • htmlAttributes (System.Object) –
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

public 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

public virtual 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)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

public 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)
Arguments:
  • viewContext (Microsoft.AspNet.Mvc.ViewContext) –
  • modelExplorer (Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer) –
  • optionLabel (System.String) –
  • expression (System.String) –
  • selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) –
  • currentValues (System.Collections.Generic.IReadOnlyCollection{System.String}) –
  • allowMultiple (System.Boolean) –
  • htmlAttributes (System.Object) –
Return type:

Microsoft.AspNet.Mvc.Rendering.TagBuilder

public virtual 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

public virtual 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

public virtual 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

public virtual 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

public virtual 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}

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

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

public virtual IReadOnlyCollection<string> GetCurrentValues(ViewContext viewContext, ModelExplorer modelExplorer, string expression, bool allowMultiple)
GetValidationAttributes(Microsoft.AspNet.Mvc.ViewContext, Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String)
Arguments:
Return type:

System.Collections.Generic.IDictionary{System.String,System.Object}

protected virtual IDictionary<string, object> GetValidationAttributes(ViewContext viewContext, ModelExplorer modelExplorer, string expression)