【发布时间】:2016-07-31 12:47:24
【问题描述】:
如果 FlagAccessEdit =false,如何禁用或只读?
public static MvcHtmlString CCheckBox(this HtmlHelper htmlHelper,
字符串名称,对象 htmlAttributes,
bool FlagAccessEdit = true, bool FlagAccessView = true)
{
如果 (!FlagAccessView)
返回 MvcHtmlString.Empty;
else if (!FlagAccessEdit && FlagAccessView)
{
返回 htmlHelper.CheckBox(name, htmlAttributes);
}
别的
返回 htmlHelper.CheckBox(name, htmlAttributes);
}
【问题讨论】:
-
如何使禁用或只读 id FlagAccessEdit =false?
-
如果此评论是问题的一部分,您应该将其编辑到问题中,而不是作为评论。
-
Ashish Shukla 的回答显示了一种解决方案,但重点是什么。没有只读复选框之类的东西,禁用它意味着您总是回发
false,即使该复选框最初显示为选中(true),这无疑会搞砸您的应用程序。如果你想这样做,为某个文本的值生成一个隐藏的输入(比如“是”或“否”)
标签: asp.net-mvc c#-4.0