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

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

Declaration
public RadzenTemplateForm<TItem>()

Properties

Actionlink

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

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

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

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

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

Returns the validity of the form.

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

Methodlink

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

Obsolete. Use InvalidSubmit instead.

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

Submitlink

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

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

BuildRenderTreelink

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

FindComponentlink

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

GetComponentCssClasslink

Declaration
protected override string GetComponentCssClass()
Returns
Type Description
string

OnParametersSetlink

Declaration
protected override void OnParametersSet()

OnSubmitlink

Handles the submit event of the form.

Declaration
protected Task OnSubmit()
Returns
Type Description
Task

RemoveComponentlink

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 🗙