I’m writing a web app with Radzen components.
I want to add a logout button in my app’s header, but clicking the button doesn’t fire its Click event.
Such issues have popped up before for me, and the answer was @rendermode=InteractiveServer somewhere, but this time I can’t figure out where, or if there’s something else
Here’s my MainLayout.razor:
@inherits LayoutComponentBase
@inject NavigationManager navigationManager
@inject SignInManager<ApplicationUser> signInManager
@inject ILogger<MainLayout> logger
<RadzenComponents @rendermode="RenderMode.InteractiveServer" />
<div class="layout-base">
<div class="header">
<div class="h-stack justify-split align-center">
<div class="logo">
<a href="/">
<img src="img/MyLogo.svg" />
</a>
</div>
<div class="h-stack justify-end align-center gap-2" style="padding-right: 2rem;">
<AuthorizeView>
<Authorized>
<!-- It shows up, but DOES NOT WORK -->
<RadzenButton Icon="logout" Click="@(args => OnLogoutClicked())" />
</Authorized>
<NotAuthorized>
<RadzenButton Icon="login" Style="min-width:40px" Click="@(args => navigationManager.NavigateTo("/Account/Login"))" />
<RadzenButton Icon="person_add_alt" Style="min-width:40px" Click="@(args => navigationManager.NavigateTo("/Account/Register"))" />
</NotAuthorized>
</AuthorizeView>
</div>
</div>
</div>
<div class="main">
<AuthorizeView>
<Authorized>
<RadzenContentContainer Name="main">
@Body
</RadzenContentContainer>
</Authorized>
<NotAuthorized>
<!-- TODO: add login/register component here ->
<h1>Not signed in</h1>
<h2>Please sign in or register</h2>
</NotAuthorized>
</AuthorizeView>
</div>
<div class="footer">
</div>
</div>