我的 asp.net MVC Web 应用程序中有以下两个下拉列表:-
<div>
<span class="f">Role</span>
@Html.DropDownListFor(model =>model.Server.RoleID, ((IEnumerable<TMS.Models.TechnologyRole>)ViewBag.TechRole).Select(option => new SelectListItem {
Text = (option == null ? "None" : option.Name),
Value = option.RoleID.ToString(),
Selected = (Model.Server != null) && (option.RoleID == Model.Server.RoleID)
}), "Choose...")
@Html.ValidationMessageFor(model =>model.Server.RoleID)
</div>
<div>
<span class="f">Virtual Center</span>
@Html.DropDownListFor(model =>model.Server.VirtualCenterID, ((IEnumerable<TMS.Models.TMSServer>)ViewBag.Servers).Select(option => new SelectListItem {
Text = (option == null ? "None" : option.Technology.Tag),
Value = option.TMSServerID.ToString(),
Selected = (Model.Server != null) && (Model.Server != null) && (option.TMSServerID == Model.Server.VirtualCenterID)
}), "Choose...")
@Html.ValidationMessageFor(model =>model.Server.VirtualCenterID)
</div>
现在我需要以下内容:-
仅当角色下拉列表值 = “虚拟服务器”时才启用虚拟中心下拉列表。
如果用户取消选择“虚拟服务器”值,则清除虚拟中心下拉列表的选择并将其禁用。
谁能建议我如何实现这一点?