[英]How to disable a DropDownListFor in MVC3 Razor?
我有这个工作和平的代码,显示在我的MVC3 Razor Web应用程序中填充DropDownList。
@Html.DropDownListFor(x => x.ReminderTime,
new SelectList(Model.RemindersList, "Item1 ", "Item2"))
我需要保持DropDownList已填充但禁用它,因此用户无法在列表中选择值。
你能指出我正确的方向吗? 请提供一些代码示例。 谢谢!
像这样,通过指定HTML属性。 DropDownListFor
@Html.DropDownListFor(
x => x.ReminderTime,
Model.RemindersList,
new { disabled = "disabled" }
)
我的解决方案归功于Ravi hit
@Html.DropDownListFor(x => x.ReminderTime,
new SelectList(Model.RemindersList, "Item1 ", "Item2"), new { disabled = "disabled" })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.