Hi,
I try to triggered the api when the checkbox is true. The checkbox is placed in Edit form as follow.
Edir.razor
<FormEdit ButtonText="Update" dev="dev"
OnValidSubmit="@EditDeveloper" />
@code {
[Parameter] public int developerId { get; set; }
Developer dev = new Developer();
protected async override Task OnParametersSetAsync()
{
dev = await http.GetFromJsonAsync<Developer>($"api/developer/{developerId}");
}
async Task EditDeveloper()
{
await http.PutAsJsonAsync("api/developer", dev);
// await http.GetAsync($"api/developer/SelectEcoById/{developerId}");
await js.InvokeVoidAsync("alert", $"Updated Successfully!");
uriHelper.NavigateTo("developer");
}
}
If I don't want to call the api when I update edit page I must not put here await http.GetAsync($"api/developer/SelectEcoById/{developerId}");
FormEdit.razor
<EditForm Model="@dev" OnValidSubmit="@OnValidSubmit">
<DataAnnotationsValidator />
<RadzenCheckBox @bind-Value="dev.ECOSelected" Name="CheckBox1" TValue="bool"/>
@code{
[Parameter] public Developer dev { get; set; }
[Parameter] public EventCallback OnValidSubmit { get; set; }
[Parameter] public int developerId { get; set; }
private async void HandleValidation()
{
var checkboxvalue = dev.ECOSelected;
if (checkboxvalue == true)
{
await http.GetAsync($"api/developer/SelectEcoById/{developerId}");
}
}
}
So, I've to call the api method in FormEdit but I don't know how I can do it?
I know that is not the radzen issue, but I will appreciate your support.
The api SelectEcoById must take a number with the specific format and only when the checkbox is true.
Thanks in advance