Hello, I have a Blazor .NET 8 WebApp application with Radzen.
I have a template form, which should call an OnSubmit() method, however nothing triggers.
The RadzenRequiredValidator doesn't work either.
When I debug, no error console, output, google chrome console etc....
I have exactly the same code for another application and it works.
Razor :
@using Idemia.SmartServices.Orchestrator.Services.Configuration.Models
<RadzenTemplateForm TItem="ConfigurationModel" Submit=@((ConfigurationModel args) => { OnSubmit(); }) InvalidSubmit=@OnInvalidSubmit>
<RadzenStack Gap="1rem">
<RadzenRow AlignItems="AlignItems.Center">
<RadzenColumn Size="12" SizeMD="4">
<RadzenLabel Text="Login :" />
</RadzenColumn>
<RadzenColumn Size="12" SizeMD="8">
<RadzenTextBox @bind-Value="config.Login" Style="width:100%" Name="Login" />
<RadzenRequiredValidator Component="Login" Text="Login is required" />
</RadzenColumn>
</RadzenRow>
<RadzenRow AlignItems="AlignItems.Center">
<RadzenColumn Size="12" SizeMD="4">
<RadzenLabel Text="Password :" />
</RadzenColumn>
<RadzenColumn Size="12" SizeMD="8">
<RadzenPassword @bind-Value="config.Password" Style="width:100%" Name="Password" />
<RadzenRequiredValidator Component="Password" Text="Password is required" />
</RadzenColumn>
</RadzenRow>
<RadzenRow AlignItems="AlignItems.Center">
<RadzenColumn Size="12" SizeMD="4">
<RadzenLabel Text="Customer Reference :" />
</RadzenColumn>
<RadzenColumn Size="12" SizeMD="8">
<RadzenTextBox @bind-Value="config.CustomerReference" Style="width:100%" Name="CustomerReference" />
<RadzenRequiredValidator Component="CustomerReference" Text="Customer reference is required" />
</RadzenColumn>
</RadzenRow>
</RadzenStack>
<RadzenStack Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.Center" Gap="1rem" Class="rz-mt-8 rz-mb-4">
<RadzenButton ButtonType="ButtonType.Submit" Text="Submit" />
</RadzenStack>
</RadzenTemplateForm>
Razor.cs :
using Idemia.SmartServices.Orchestrator.Services.Configuration.Models;
using Microsoft.AspNetCore.Components;
using Radzen;
namespace Idemia.SmartServices.Orchestrator.Web.Components.Pages.Configuration
{
public partial class AddConfigurationDialog
{
[Inject]
protected NavigationManager NavigationManager { get; set; }
[Inject]
protected DialogService DialogService { get; set; }
[Inject]
protected TooltipService TooltipService { get; set; }
[Inject]
protected ContextMenuService ContextMenuService { get; set; }
[Inject]
protected NotificationService NotificationService { get; set; }
public ConfigurationModel config = new ConfigurationModel();
void OnInvalidSubmit()
{
NotificationService.Notify(NotificationSeverity.Error, "Create invalid");
}
private void OnSubmit()
{
DialogService.Close(config);
}
}
}
Model :
public class ConfigurationModel
{
[Key]
public int Id { get; set; }
public string Login { get; set; } = string.Empty;
public string? Password { get; set; } = string.Empty;
public string? CustomerReference { get; set; } = string.Empty;
}