Class RadzenTemplateForm<TItem>
A component which represents a form
. Provides validation support.
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenTemplateForm<TItem> : RadzenComponent, IDisposable, 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()
Initializes a new instance of the RadzenTemplateForm<TItem> class.
Declaration
public RadzenTemplateForm()
Properties
Action
Specifies the form action
attribute. When set the form submits to the specified URL.
Declaration
public string Action { get; set; }
Property Value
Type | Description |
---|---|
System.String |
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>
ChildContent
Gets or sets the child content.
Declaration
public RenderFragment<EditContext> ChildContent { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment<EditContext> |
Data
Specifies the model of the form. Required to support validation.
Declaration
public TItem Data { get; set; }
Property Value
Type | Description |
---|---|
TItem |
EditContext
Gets or sets the edit context.
Declaration
public EditContext EditContext { get; set; }
Property Value
Type | Description |
---|---|
EditContext | The edit context. |
InvalidSubmit
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> |
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)
{
}
}
IsValid
Returns the validity of the form.
Declaration
public bool IsValid { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Method
Specifies the form method
attribute. Used together with Action.
Declaration
public string Method { get; set; }
Property Value
Type | Description |
---|---|
System.String |
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>
OnInvalidSubmit
Obsolete. Use InvalidSubmit instead.
Declaration
public EventCallback<FormInvalidSubmitEventArgs> OnInvalidSubmit { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<FormInvalidSubmitEventArgs> |
Submit
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> |
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
AddComponent(IRadzenFormComponent)
Adds the specified component to the form.
Declaration
public void AddComponent(IRadzenFormComponent component)
Parameters
Type | Name | Description |
---|---|---|
IRadzenFormComponent | component | The component to add to the form. |
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
RenderTreeBuilder | builder |
FindComponent(String)
Finds a form component by its name.
Declaration
public IRadzenFormComponent FindComponent(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
Returns
Type | Description |
---|---|
IRadzenFormComponent | The component whose Name equals to |
GetComponentCssClass()
Gets the component CSS class.
Declaration
protected override string GetComponentCssClass()
Returns
Type | Description |
---|---|
System.String |
Overrides
OnParametersSet()
Declaration
protected override void OnParametersSet()
OnSubmit()
Handles the submit event of the form.
Declaration
protected async Task OnSubmit()
Returns
Type | Description |
---|---|
Task |
RemoveComponent(IRadzenFormComponent)
Removes the component from the form.
Declaration
public void RemoveComponent(IRadzenFormComponent component)
Parameters
Type | Name | Description |
---|---|---|
IRadzenFormComponent | component | The component to remove from the form. |