, but that is obviously not working. Any ot" /> , but that is obviously not working. Any ot" /> , but that is obviously not working. Any ot"/>

How to disable InputRadioGroup?

320 Views Asked by At

Is there a way to disable InputRadioGroup in blazor webassembly?

I tried <InputRadioGroup Disabled="false">, but that is obviously not working. Any other way?

2

There are 2 best solutions below

0
Brian Parker On

Wrap the <InputRadioGroup> in a <fieldset> and disable that.

<fieldset disabled="@true">
    <InputRadioGroup @bind-Value="answer">
        @foreach (var option in Question.Options)
        {
            <label class="me-3 form-check-label">
                <InputRadio class="form-check-input me-1" Value="@option" />
                @option
            </label>
        }
    </InputRadioGroup>
</fieldset>

The <InputRadioGroup> does not output any HTML. It outputs a CascadingValue CascadingValue<InputRadioContext> and its ChildContent only.

Source Code

0
Booji Boy On

You can't disable the group but you can disable each InputRadio:

    <InputRadioGroup @bind-Value="@CurrentlySelectedAnswer">
        @foreach (Answer a in Answers)
        {
            <p>
                <InputRadio Value="@a.Answer_ID" disabled="@IsReadOnly" />
                @a.Answer_Text
            </p>
        }
    </InputRadioGroup>