RadzenTemplateForm<TItem> Class

A component which represents a form. Provides validation support.

Inheritance

Object

ComponentBase

RadzenComponent

RadzenTemplateForm<TItem>

Implements

IComponent

IHandleEvent

IHandleAfterRender

IRadzenForm

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class RadzenTemplateForm<TItem> : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender, IRadzenForm

Type Parameters

Name Description
TItem

Examples

<RadzenTemplateForm TItem="Model" Data=@model>
  <RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
  <RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
@code {
 class Model
 {
   public string Email { get; set; }
 }

 Model model = new Model();
}

Constructors

RadzenTemplateForm<TItem>Link to this section

Initializes a new instance of the RadzenTemplateForm<T> class.

Declaration
public RadzenTemplateForm<TItem>()

Properties

ActionLink to this section

Specifies the form action attribute. When set the form submits to the specified URL.

Declaration
public string Action { get; set; }
Property Value
Type Description
stringSpecifies the form action attribute. When set the form submits to the specified URL.
Examples
<RadzenTemplateForm TItem="Model" Method="post" Action="/register" Data=@model>
  <RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
  <RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>

ChildContentLink to this section

Gets or sets the child content.

Declaration
public RenderFragment<Forms.EditContext> ChildContent { get; set; }
Property Value
Type Description
RenderFragment<Forms.EditContext>Gets or sets the child content.

DataLink to this section

Specifies the model of the form. Required to support validation.

Declaration
public TItem Data { get; set; }
Property Value
Type Description
TItemSpecifies the model of the form. Required to support validation.

EditContextLink to this section

Gets or sets the edit context.

Declaration
public Forms.EditContext EditContext { get; set; }
Property Value
Type Description
Forms.EditContextGets or sets the edit context.

InvalidSubmitLink to this section

A callback that will be invoked when the user submits the form and IsValid is false.

Declaration
public EventCallback<FormInvalidSubmitEventArgs> InvalidSubmit { get; set; }
Property Value
Type Description
EventCallback<FormInvalidSubmitEventArgs>A callback that will be invoked when the user submits the form and IsValid is false.
Examples
<RadzenTemplateForm TItem="Model" InvalidSubmit=@OnInvalidSubmit Data=@model>
  <RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
  <RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
@code {
 class Model
 {
   public string Email { get; set; }
 }

 Model model = new Model();

 void OnInvalidSubmit(FormInvalidSubmitEventArgs args)
 {

 }
}

IsValidLink to this section

Returns the validity of the form.

Declaration
public bool IsValid { get; }
Property Value
Type Description
boolReturns the validity of the form.

MethodLink to this section

Specifies the form method attribute. Used together with Action.

Declaration
public string Method { get; set; }
Property Value
Type Description
stringSpecifies the form method attribute. Used together with Action.
Examples
<RadzenTemplateForm TItem="Model" Method="post" Action="/register" Data=@model>
  <RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
  <RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>

OnInvalidSubmitLink to this section

Obsolete. Use InvalidSubmit instead.

Declaration
public EventCallback<FormInvalidSubmitEventArgs> OnInvalidSubmit { get; set; }
Property Value
Type Description
EventCallback<FormInvalidSubmitEventArgs>Obsolete. Use InvalidSubmit instead.

SubmitLink to this section

A callback that will be invoked when the user submits the form and IsValid is true.

Declaration
public EventCallback<TItem> Submit { get; set; }
Property Value
Type Description
EventCallback<TItem>A callback that will be invoked when the user submits the form and IsValid is true.
Examples
<RadzenTemplateForm TItem="Model" Submit=@OnSubmit Data=@model>
  <RadzenTextBox style="display: block" Name="Email" @bind-Value=@model.Email />
  <RadzenRequiredValidator Component="Email" Text="Email is required" Style="position: absolute" />
</RadzenTemplateForm>
@code {
 class Model
  {
   public string Email { get; set; }
 }

 Model model = new Model();

 void OnSubmit(Model value)
 {

 }
}

Methods

AddComponentLink to this section

Declaration
public void AddComponent(IRadzenFormComponent component)
Parameters
Type Name Description
IRadzenFormComponent component

BuildRenderTreeLink to this section

Declaration
protected override void BuildRenderTree(Rendering.RenderTreeBuilder builder)
Parameters
Type Name Description
Rendering.RenderTreeBuilder builder

FindComponentLink to this section

Declaration
public IRadzenFormComponent FindComponent(string name)
Parameters
Type Name Description
string name
Returns
Type Description
IRadzenFormComponent

GetComponentCssClassLink to this section

Declaration
protected override string GetComponentCssClass()
Returns
Type Description
string

OnParametersSetLink to this section

Declaration
protected override void OnParametersSet()

OnSubmitLink to this section

Handles the submit event of the form.

Declaration
protected Task OnSubmit()
Returns
Type Description
Task

RemoveComponentLink to this section

Declaration
public void RemoveComponent(IRadzenFormComponent component)
Parameters
Type Name Description
IRadzenFormComponent component
An error has occurred. This app may no longer respond until reloaded. Reload 🗙