Class HtmlCreator
Helper class that creates HTML for a view.
Inheritance
Inherited Members
Namespace: ChameleonForms.Templates
Assembly: ChameleonForms.Core.dll
Syntax
public static class HtmlCreator
Methods
| Improve this Doc View SourceBuildButton(IHtmlContent, String, String, String, HtmlAttributes)
Creates the HTML for a submit <button>.
Declaration
public static IHtmlContent BuildButton(IHtmlContent content, string type = null, string id = null, string value = null, HtmlAttributes htmlAttributes = null)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Html.IHtmlContent | content | The content to display for the button |
System.String | type | The type of submit button; submit (default) or reset |
System.String | id | The id/name to use for the button |
System.String | value | The value to submit with the button |
HtmlAttributes | htmlAttributes | Any HTML attributes that should be applied to the button |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the submit button |
BuildButton(String, String, String, String, HtmlAttributes)
Creates the HTML for a submit <button>.
Declaration
public static IHtmlContent BuildButton(string text, string type = null, string id = null, string value = null, HtmlAttributes htmlAttributes = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to display for the button |
System.String | type | The type of submit button; submit (default) or reset |
System.String | id | The id/name to use for the button |
System.String | value | The value to submit with the button |
HtmlAttributes | htmlAttributes | Any HTML attributes that should be applied to the button |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the submit button |
BuildFormTag(String, FormMethod, HtmlAttributes, Nullable<EncType>)
Creates the HTML for a form tag.
Declaration
public static IHtmlContent BuildFormTag(string action, FormMethod method, HtmlAttributes htmlAttributes = null, EncType? encType = default(EncType? ))
Parameters
Type | Name | Description |
---|---|---|
System.String | action | The URL the form submits to |
Microsoft.AspNetCore.Mvc.Rendering.FormMethod | method | The HTTP method the form submits with |
HtmlAttributes | htmlAttributes | Any HTML attributes that should be applied to the form; specified as an anonymous object |
System.Nullable<EncType> | encType | The encoding type the form uses |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the form |
BuildInput(String, String, String, HtmlAttributes)
Creates the HTML for an input.
Declaration
public static IHtmlContent BuildInput(string name, string value, string type, HtmlAttributes htmlAttributes)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name/id of the input |
System.String | value | The value of the input |
System.String | type | The type of the input |
HtmlAttributes | htmlAttributes | Any HTML attributes that should be applied to the button |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the input |
BuildLabel(String, IHtmlContent, HtmlAttributes)
Creates the HTML for a label.
Declaration
public static IHtmlContent BuildLabel(string for, IHtmlContent labelText, HtmlAttributes htmlAttributes)
Parameters
Type | Name | Description |
---|---|---|
System.String | for | The name/id for the checkbox |
Microsoft.AspNetCore.Html.IHtmlContent | labelText | The text inside the label |
HtmlAttributes | htmlAttributes | Any HTML attributes that should be applied to the checkbox |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the checkbox |
BuildSelect(String, IEnumerable<SelectListItem>, Boolean, HtmlAttributes)
Creates the HTML for a select.
Declaration
public static IHtmlContent BuildSelect(string name, IEnumerable<SelectListItem> selectListItems, bool multiple, HtmlAttributes htmlAttributes)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name/id of the select |
System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> | selectListItems | The items for the select list |
System.Boolean | multiple | Whether or not multiple items can be selected |
HtmlAttributes | htmlAttributes | Any HTML attributes that should be applied to the select |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the select |
BuildSingleCheckbox(String, Boolean, HtmlAttributes, String)
Creates the HTML for a single checkbox.
Declaration
public static IHtmlContent BuildSingleCheckbox(string name, bool isChecked, HtmlAttributes htmlAttributes, string value = "true")
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name/id for the checkbox |
System.Boolean | isChecked | Whether or not the checkbox is currently checked |
HtmlAttributes | htmlAttributes | Any HTML attributes that should be applied to the checkbox |
System.String | value | The value to submit when the checkbox is ticked |
Returns
Type | Description |
---|---|
Microsoft.AspNetCore.Html.IHtmlContent | The HTML for the checkbox |