Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor EventCallback from a SSR parent to an InteractiveServer Child Component is Null

$
0
0

I have a SSR Parent component with a Child component with InteractiveServer render mode. I need this child component to be interactive so that I can bind to events like @onclick etc. I want to pass data/value back to the parent using EventCallback but this delegate is never set I guess due to different render modes, is there another way to do this?

Parent.razor

<Child  @rendermode="InteractiveServer"  OnNameEntered="@DisplayName"/>@code {  public void DisplayName(string result) {     Console.WriteLine($"Result is {result}");  }}

Child.razor

<input @bind="name"/><button type="button" @onclick="NameEntered">Click</button>@code {  [Parameter]  public EventCallback<string> OnNameEntered { get; set; }  private string name;  public async Task NameEntered() {    await OnNameEntered.InvokeAsync(name);  }

I tried removing the InteractiveRender mode on the child and the delegate would properly pass to the child but then it would remove all interactivity within that component.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>