禁用 MVcContrib.FluentHtml.CheckboxList 中的复选框
我刚刚开始发现 FluentHml,并且我被 CheckBoxList Helper 困住了。
这是代码
<ul>
<%=this.CheckBoxList(m=>m.Filter)
.Options(criteria.Choices, x => x.Code, x => x.DisplayText)
.Selected(Model.Filter)
.Label(criteria.Label).ItemFormat("<li> {0} </li>")
%>
</ul>
所以,我有一个基于“criteria.Choices”的复选框列表,其类型为 List
这是 ChoiceViewModel 的代码
public class ChoiceViewModel
{
// Some stuff
public string Code { get{ return _code; } }
public string Label { get { return _label; }}
public string DisplayText { get { return _displayText;}
}
}
,我的问题是: 我想在某种条件下禁用该复选框。
假设如果代码不是以“A”开头,我想禁用该复选框
如何实现?
谢谢, 哈桑
I have just started to discover FluentHml and I'm stuck with the CheckBoxList Helper.
Here is the code
<ul>
<%=this.CheckBoxList(m=>m.Filter)
.Options(criteria.Choices, x => x.Code, x => x.DisplayText)
.Selected(Model.Filter)
.Label(criteria.Label).ItemFormat("<li> {0} </li>")
%>
</ul>
So, I have a checkboxlist based on "criteria.Choices" which is typed as List<ChoiceViewModel>.
Here is the code of a ChoiceViewModel
public class ChoiceViewModel
{
// Some stuff
public string Code { get{ return _code; } }
public string Label { get { return _label; }}
public string DisplayText { get { return _displayText;}
}
}
And my problem is :
I want to disable the checkbox under a condition.
Let's say that if the Code doesn't start with an "A", I want to disable the checkbox
How can I achieve that ?
Thanks,
Hasan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CheckboxList 没有提供这一点。您可以使用循环中的 CheckBox 来完成此操作。像这样的东西:
CheckboxList does not provide that. You can do it with CheckBox in loop. Something like this: