There is a code

<table> <tr> <td>@Html.DropDownList("Depatrments", "Выберите Одно")</td> <td>@Html.DropDownList("Arr")</td> </tr> <tr> <td>@Html.DropDownList("AArmors", "Выберите Другое")</td> </tr> </table> @Html.RadioButton("Active", "false", true) No @Html.RadioButton("Active", "true") Yes 

How and where (in a view or controller) do the dropdownlist depend on radiobutton? In webforms, the radio buttons method was simply generated and the combobox was controlled using the Enabled property.

    1 answer 1

    If you do in the view, you can do it through jQuery:

     <label class="radio-inline"> <input name="type" id="disable" value="1" checked="" type="radio" class="control"> Disable dropdown </label> <label class="radio-inline"> <input name="type" id="enable" value="0" type="radio" class="control"> Enable dropdown </label> @Html.DropDownList("Depatrments", "Выберите Одно") 

    Script:

     $("#Depatrments").attr("disabled", "disabled"); $(".control").change(function () { if ($(this).val() == "1") { $("#Depatrments").attr("disabled", "disabled").val(''); //#Depatrments - Id списка } else { $("#Depatrments").removeAttr("disabled"); } }); 
    • I may be doing something wrong, but my dropdownlist is active with both radiobutton pressed. - cruim
    • look here if there are errors correct link to .net Fiddle - Ruslan_K
    • solved the problem, thanks. - cruim