Triggered api method with checkbox in EditForm

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

Hi @SCosmos,

You can probably use the Change event of RadzenCheckbox to invoke your method:

<RadzenCheckBox Change=@(HandleValidation) @bind-Value="dev.ECOSelected" Name="CheckBox1" TValue="bool" /> 

Finally I changed the configuration of my code. i.e.
EditForm becomes

<EditForm Model="@dev" OnValidSubmit="@OnValidSubmit">
     <DataAnnotationsValidator />
    
 <RadzenCheckBox @bind-Value="dev.ECOSelected" Name="CheckBox1" TValue="bool"/>   
    
 @code{    
     [Parameter] public Developer dev { get; set; }
 }

Edit.razor becomes

<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}");  // here I added Get method
         await js.InvokeVoidAsync("alert", $"Updated Successfully!");
         uriHelper.NavigateTo("developer");        
      }        
        
  }

I modified the api controller as below

 [HttpGet("SelectEcoById/{id}")]
         public async Task<ActionResult<Developer>> SelectEcoById(int id)
        {
            var developer = await _context.Developers.FindAsync(id);
            if (developer == null)
            {
                return NotFound();
            }               
            if (!developer.ECOSelected)
            {
               var values = await GenerateEcoByIdAsync(id);
                
                    developer.ECOYear = values.Year;
                    developer.ECOCount = values.Count;
                    developer.ECOSelected = false;                  

                await _context.SaveChangesAsync();
            }
            return developer;
        }

Thanks to your support. I will try your proposition that seems correct!