Show / Hide Table of Contents

    Class FormComponent<TModel>

    Chameleon Forms base component class; provides an ability to easily write HTML to the page in a self-closing or nested manner. Ensure you call Initialise() at the end of the constructor when extending this class.

    Inheritance
    System.Object
    FormComponent<TModel>
    Field<TModel>
    Message<TModel>
    Navigation<TModel>
    Section<TModel>
    Implements
    IFormComponent<TModel>
    Microsoft.AspNetCore.Html.IHtmlContent
    System.IDisposable
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: ChameleonForms.Component
    Assembly: ChameleonForms.dll
    Syntax
    public abstract class FormComponent<TModel> : IFormComponent<TModel>, IHtmlContent, IDisposable
    Type Parameters
    Name Description
    TModel

    Constructors

    | Improve this Doc View Source

    FormComponent(IForm<TModel>, Boolean)

    Create a form component.

    Declaration
    protected FormComponent(IForm<TModel> form, bool isSelfClosing)
    Parameters
    Type Name Description
    IForm<TModel> form

    The form

    System.Boolean isSelfClosing

    Whether or not the component is self closing or has an explicit end tag

    Fields

    | Improve this Doc View Source

    IsSelfClosing

    Whether or not the component is self-closing when instantiated or Dispose will be called later.

    Declaration
    protected readonly bool IsSelfClosing
    Field Value
    Type Description
    System.Boolean

    Properties

    | Improve this Doc View Source

    Form

    The form that the component is attached to.

    Declaration
    public IForm<TModel> Form { get; }
    Property Value
    Type Description
    IForm<TModel>

    Methods

    | Improve this Doc View Source

    Begin()

    Returns the HTML representation of the beginning of the form component.

    Declaration
    public abstract IHtmlContent Begin()
    Returns
    Type Description
    Microsoft.AspNetCore.Html.IHtmlContent

    The beginning HTML for the form component

    | Improve this Doc View Source

    Dispose()

    Called when form component is created within a using block: writes the end tag(s) of the component.

    Declaration
    public virtual void Dispose()
    | Improve this Doc View Source

    End()

    Returns the HTML representation of the end of the form component.

    Declaration
    public abstract IHtmlContent End()
    Returns
    Type Description
    Microsoft.AspNetCore.Html.IHtmlContent

    The ending HTML for the form component

    | Improve this Doc View Source

    Initialise()

    Initialises the form component; should be called at the end of the constructor of any derived classes. Writes HTML directly to the page is the component isn't self-closing

    Declaration
    public void Initialise()
    | Improve this Doc View Source

    WriteTo(TextWriter, HtmlEncoder)

    Called when form component outputted to the page; writes the form content HTML to the given writer.

    Declaration
    public void WriteTo(TextWriter writer, HtmlEncoder encoder)
    Parameters
    Type Name Description
    System.IO.TextWriter writer

    The writer to write to

    System.Text.Encodings.Web.HtmlEncoder encoder

    The HTML encoder to use when writing

    Implements

    IFormComponent<TModel>
    Microsoft.AspNetCore.Html.IHtmlContent
    System.IDisposable

    Extension Methods

    HtmlAttributesExtensions.ToHtmlAttributes(Object)
    HtmlContentExtensions.ToHtmlString(IHtmlContent)
    • Improve this Doc
    • View Source
    Back to top © Copyright 2012-2020 MRCollective, Rob Moore, Matt Davies and the contributors to ChameleonForms.