Click here to Skip to main content
15,667,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i am trying to call a delete function as event call back and component parameter. I am unable to trigger the delete operation which is triggered from the child component.Getting above errorr.Any ideas what I'm doing wrong in child to parent communication? consider both my empdisabled(child) and empnormal class having same getting values when its constructor invoked by passing empnormal(parent component) object

What I have tried:

In Child Component
   public EventCallback<empdisabled> FiletoDelete { get; set; }

  <button OnClick="() => FiletoDelete.InvokeAsync(context)"/>

In Parent

//CreateEmpForm-is class i have written RemoveFile mtd

<Child FileToDelete="@(variant=>createMediaNewForm.RemoveFile(variant.FIle))" ></Child>

 public async Task RemoveFile(empNormal file)


child class

public class empdisabled
       private empnormal file;

       public empdisabled(empnormal file)
           File = file;
           this.file = file;

Updated 12-Jan-23 5:34am

1 solution

You should be passing by CascadingParamemter from the parent to the Child Component. Read more here: Blazor University - Cascading values[^]


I almost forgot my article, this is a different way of doing what you want: Blazor Component Callback from a RenderFragment Template[^] . It is a more specialized case though.
Share this answer
PIEBALDconsult 12-Jan-23 19:16pm    
Not CaptainParamemter ?
Graeme_Grant 12-Jan-23 21:47pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900