Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Blazor Radio Buttons Binding - Preview 8 - test it here - https://blazorfiddle.com/s/2e9zk56j
@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>
@functions
{
string RadioValue = "aspnetcore";
void RadioSelection(UIChangeEventArgs args)
{
RadioValue = args.Value.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.