Search code examples
c#asp.net-coreblazor-server-side.net-8.0

Blazor WebApp InputRadioGroup no longer works after upgrade from .NET 6 to .NET 8


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;
}

Solution

  • There'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;
    }
    

    enter image description here