Skip to content

Instantly share code, notes, and snippets.

@SQL-MisterMagoo
Last active October 28, 2024 07:08
Show Gist options
  • Select an option

  • Save SQL-MisterMagoo/bc5713fb26bf84bf810d48d1f45c361a to your computer and use it in GitHub Desktop.

Select an option

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();
}
}
@nsenthilmurugan
Copy link
Copy Markdown

Good Stuff, Keep it up :)

@dodyg
Copy link
Copy Markdown

dodyg commented Aug 16, 2020

Which SDK is this? The RC one? I can't find the preview 8

@SQL-MisterMagoo
Copy link
Copy Markdown
Author

Which SDK is this? The RC one? I can't find the preview 8

Sorry that was 0.8 - way before release - I've updated to work on the current released version

@dodyg
Copy link
Copy Markdown

dodyg commented Aug 16, 2020

The latest version of VS Preview doesn't run .NET 5.0 RC nightly build properly unfortunately :(

@SQL-MisterMagoo
Copy link
Copy Markdown
Author

Not sure what that had to do with this sample, which will work on the current official release?

@dodyg
Copy link
Copy Markdown

dodyg commented Aug 16, 2020

Oh ok. I didn't realize Preview 7 (current release) has support InputRadio. Because according to this tweet it's only available on Preview 8.

@SQL-MisterMagoo
Copy link
Copy Markdown
Author

It doesn't, this sample shows how to use native html radio inputs

@dodyg
Copy link
Copy Markdown

dodyg commented Aug 16, 2020

ah got it. Thanks.

@coultonluke
Copy link
Copy Markdown

Beautiful thanks. I don't know why the documentation doesn't work for this but this saved me time thanks!

@cfob
Copy link
Copy Markdown

cfob commented Jan 31, 2021

Only working example I have found. Many thanks.

@0ptim
Copy link
Copy Markdown

0ptim commented Jul 30, 2021

Thanks a lot! 💯

@chrisdeveloperit
Copy link
Copy Markdown

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

@DesenEnterprises
Copy link
Copy Markdown

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