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

EventCallBack is not working with @rendermode.InteractiveServer on a component

$
0
0

EventCallBack is not working with @rendermode.InteractiveServer on a component.The OnClick.InvokeAsync() is called but does not execute. The parent callback is not called.

If @rendermode InteractiveServer is on the page and not the component the EventCallBack works.

I need to have InteractiveServer & InteractiveWebAssembly components on the same page.

I'm using .Net 8

Home.razor

@page "/"@* This way works *@@* @rendermode InteractiveServer *@@* <Button OnClick=@DoOnClick Text="InteractiveServer" /> *@@* This way does not work *@<Button @rendermode=InteractiveServer OnClick=@DoOnClick Text="InteractiveServer" /><p>@HelloString</p>@code {  string HelloString { get; set; } = "";  void DoOnClick()  {    HelloString = "Hello"; // Is not being called  }}

Button.razor

<button @onclick=@DoOnClick>@Text</button>@code {  [Parameter]  public EventCallback OnClick { get; set; }  [Parameter]  public string Text { get; set; } = "";  void DoOnClick()  {    OnClick.InvokeAsync(); // Is being called  }}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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