У меня есть переключатель, который в модели выбран как Нет.Но я хочу, чтобы он автоматически отключал выпадающее меню.Но если вы выберете Да, то выпадающий список работает.Я знаю, что вы можете сделать это с JQuery.Но мне было интересно, если это возможно с C # MVC.
<div class="form-group dropdownSwitchContainer">
<label class="control-label col-md-2" for="TenantGroup">Is this a Proxy Organisation?</label>
<div class="col-lg-6">
<div class="admin-form theme-primary">
<div class="radio-custom radio-primary mt10 mr10 pull-left">
@Html.RadioButtonFor(m => m.ProxyOrganisation, true, new { @class = "control-label col-md-4" })
<label for="ProxyYes">Yes</label>
</div>
<div class="radio-custom radio-primary mt10 mr10 pull-left">
@Html.RadioButtonFor(m => m.ProxyOrganisation, true, new { @class = "control-label col-md-4" })
<label for="ProxyYes">No</label>
</div>
</div>
</div>
</div>
@{
var emptyList = new List<SelectListItem>();
var proxiesList = new SelectList(emptyList);
if (proxies != null)
{
proxiesList = new SelectList(proxies, "key", "value", 0);
}
}
<div class="form-group">
<label class="control-label col-md-2" for="AlternativeShippingTarget">Alternative Shipping Target</label>
<div class="col-md-8">
@Html.DropDownListFor(x => x.ShippingTarget, proxiesList, "Choose a target...", new { id = "targetSelect", @class = "form-control", placeholder = "Choose a target..." })
@Html.ValidationMessageFor(m => m.ShippingTarget, string.Empty, new { @class = "text-danger" })
</div>
</div>
</div>
Контроллер
`var model = new ViewModels.SocietiesCreateModel
{
SocietyName = string.Empty,
CISACCode = string.Empty,
ShippingTarget = string.Empty,
ProxyOrganisation = false,
PagingInfo = new ViewModels.PagingModel
{
Page = page,
Take = take,
SortAscending = sortAsc,
SortPropertyName = sortBy
}
};`