-
-
Save donhuvy/30d033361b1f8ff114a39776c1f0fe41 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 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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment