Last active
October 28, 2024 07:08
-
-
Save SQL-MisterMagoo/bc5713fb26bf84bf810d48d1f45c361a to your computer and use it in GitHub Desktop.
Blazor Radio Buttons Binding - test it here - https://blazorfiddle.com/s/3b18q1ix OR https://blazorrepl.com/repl/GYkiPqED26m9cBlb33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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(); | |
} | |
} |
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
Thank you for this! Wish I found it days ago. It should be in the Blazor documentation.