Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
0
Blazor Radio and Radio Group
posted

I am looking for help with controlling radio buttons with code and we can skip the setup stuff.

Below is the starting HTML code and the text is hard coded.

<IgbRadioGroup>
<IgbRadio>Apple</IgbRadio>
<IgbRadio>Orange</IgbRadio>
</IgbRadioGroup>

I want to be able to do the following:
set checkmarks
get checkmarks

@code{

????

}

  • 34830
    Verified Answer
    Offline posted

    Hello Dean,

    In order to get and set the checkmarks of the IgbRadio buttons, I would recommend that you “ref” the IgbRadio elements and then you can set their corresponding “Checked” properties. To “ref” the IgbRadio elements, you could do something like the following:

    <IgbRadio @ref=”AppleRadioRef”>Apple</IgbRadio>

    @code {
        public IgbRadio AppleRadioRef{get;set;}
    }

    From there, you can get or set the checked status of the radio button by getting or setting the “Checked” property of the AppleRadioRef.

    I hope this helps you. Please let me know if you have any other questions or concerns on this matter.