小编Oll*_*lie的帖子

如何在MVC htmlAttribute中设置禁用

使用HTML Helper时,根据条件设置属性的最佳方法是什么.例如

<%if (Page.User.IsInRole("administrator")) {%>
<%=Html.TextBoxFor(m => m.FirstName, new {@class='contactDetails'}%>
<%} else {%>
<%=Html.TextBoxFor(m => m.FirstName, new {@class='contactDetails', disabled = true}%>
<%}%>
Run Code Online (Sandbox Code Playgroud)

必须有一种更好的方法以编程方式将一个额外的KeyPair添加到匿名类型?不能用

new { .... disabled = Page.User.IsInRole("administrator") ... }
Run Code Online (Sandbox Code Playgroud)

因为浏览器将任何禁用的属性值视为禁用输入

c# asp.net-mvc

19
推荐指数
3
解决办法
4万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1