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
Inherited Members
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 SourceFormComponent(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 SourceIsSelfClosing
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 SourceForm
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 SourceBegin()
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 |
Dispose()
Called when form component is created within a using
block: writes the end tag(s) of the component.
Declaration
public virtual void Dispose()
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 |
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()
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 |