Skip to content

Instantly share code, notes, and snippets.

@SQL-MisterMagoo
Last active October 31, 2021 18:35
Show Gist options
  • Save SQL-MisterMagoo/bc5713fb26bf84bf810d48d1f45c361a to your computer and use it in GitHub Desktop.
Save SQL-MisterMagoo/bc5713fb26bf84bf810d48d1f45c361a to your computer and use it in GitHub Desktop.
@foreach (var item in new string[] { "AspNetCore","AspNet","SomeJsThingWhatever"})
{
<div>
<input type="radio" name="technology" id="@item" value="@item" @onchange="RadioSelection" checked=@(RadioValue.Equals(item,StringComparison.OrdinalIgnoreCase)) />
<label for="@item">@item</label>
</div>
}
<div>
<label>Selected Value is @RadioValue</label>
</div>
@code
{
string RadioValue = "aspnetcore";
void RadioSelection(ChangeEventArgs args)
{
RadioValue = args.Value.ToString();
}
}
@cfob
Copy link

cfob commented Jan 31, 2021

Only working example I have found. Many thanks.

@0ptim
Copy link

0ptim commented Jul 30, 2021

Thanks a lot! 💯

@chrisdeveloperit
Copy link

Thank you for this! Wish I found it days ago. It should be in the Blazor documentation.

@DesenEnterprises
Copy link

This is awesome, thank you so much! Life saver...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment