Table of Contents

Class FormComponent<TProperties, TValue>

Namespace
Kentico.Forms.Web.Mvc
Assembly
Kentico.Content.Web.Mvc.dll

Represents a base class for a form component. Inherit this class to define a custom form component.

public abstract class FormComponent<TProperties, TValue> : FormComponent where TProperties : FormComponentProperties<TValue>, new()

Type Parameters

TProperties

Properties type of the form component.

TValue

Value type of the form component.

Inheritance
object
FormComponent<TProperties, TValue>
Derived
Inherited Members
Extension Methods

Remarks

Properties which are expected to have automatically bound values after form submit, have to be annotated with BindablePropertyAttribute.

Constructors

FormComponent()

Initializes a new instance of the FormComponent<TProperties, TValue> class.

protected FormComponent()

Properties

BaseProperties

Gets the form component's properties as its base type.

public override FormComponentProperties BaseProperties { get; }

Property Value

FormComponentProperties

Properties

Gets the form component's properties.

[ValidateNever]
public TProperties Properties { get; protected set; }

Property Value

TProperties

Methods

GetObjectValue()

Gets the value of the form component. The GetValue() method can be used directly to obtain the typed value.

public override object GetObjectValue()

Returns

object

Returns the value of the form component.

GetValue()

Gets the value of the form component. Implement in a subclass to return value of a desired property. Method can also be used to return a value composed of multiple properties if required.

public abstract TValue GetValue()

Returns

TValue

Returns the value of the form component.

LoadProperties(FormComponentProperties)

Loads properties of the form component. The actual properties type must match the PropertiesType.

public override void LoadProperties(FormComponentProperties properties)

Parameters

properties FormComponentProperties

Form component properties to be loaded.

Exceptions

ArgumentNullException

Thrown when properties are null.

ArgumentException

Thrown when properties do not match the PropertiesType.

SetObjectValue(object)

Sets the value of the form component. The value must be of proper type or an exception is thrown. The SetValue(TValue) method can be used directly to set the typed default value.

public override void SetObjectValue(object value)

Parameters

value object

Value to be set.

SetValue(TValue)

Sets the value of the form component. Implement in a subclass to set value of a desired property. Method can also be used to decompose passed value into several properties rendered in the resulting form component markup.

public abstract void SetValue(TValue value)

Parameters

value TValue

Value to be set.