The following code worked in .NET 6. The RadioButtons faded in one or the other Blazor component. But in .NET 8, this no longer works.
Is there a different solution now?
@page "/addaccounts"
@inject NavigationManager NavigationManager
@inject IAddAccountUseCase AddAccountUseCase
<h1>Account management</h1>
<p>
<InputRadioGroup Name="SingleOrBatch" @bind-Value="@_single">
<InputRadio Name="SingleOrBatch" Value="@true" /> Single account
<InputRadio Name="SingleOrBatch" Value="@false" /> CSV Import
</InputRadioGroup>
</p>
@if (_single)
{
<AddSingleAccountComponent></AddSingleAccountComponent>
}
else
{
<AddMultipleAccountsComponent></AddMultipleAccountsComponent>
}
@code {
private bool _single = true;
}
The following code worked in .NET 6. The RadioButtons faded in one or the other Blazor component. But in .NET 8, this no longer works.
Is there a different solution now?
@page "/addaccounts"
@inject NavigationManager NavigationManager
@inject IAddAccountUseCase AddAccountUseCase
<h1>Account management</h1>
<p>
<InputRadioGroup Name="SingleOrBatch" @bind-Value="@_single">
<InputRadio Name="SingleOrBatch" Value="@true" /> Single account
<InputRadio Name="SingleOrBatch" Value="@false" /> CSV Import
</InputRadioGroup>
</p>
@if (_single)
{
<AddSingleAccountComponent></AddSingleAccountComponent>
}
else
{
<AddMultipleAccountsComponent></AddMultipleAccountsComponent>
}
@code {
private bool _single = true;
}
Share
Improve this question
edited 18 hours ago
Zhi Lv
21.5k1 gold badge27 silver badges37 bronze badges
asked 2 days ago
fmnbgfmnbg
172 bronze badges
1 Answer
Reset to default 0There's nothing wrong with the code you've shown.
Here's my demo page:
- Render Mode: Blazor Server
- Interactivity: Global
@page "/"
<PageTitle>Home</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.
<p>
<InputRadioGroup Name="SingleOrBatch" @bind-Value="@_single">
<InputRadio Name="SingleOrBatch" Value="@true" /> Single account
<InputRadio Name="SingleOrBatch" Value="@false" /> CSV Import
</InputRadioGroup>
</p>
@if (_single)
{
<div class="bg-success text-white m-2 p-2">Single</div>
}
else
{
<div class="bg-primary text-white m-2 p-2">Multiple</div>
}
@code {
private bool _single = true;
}