【发布时间】:2011-12-02 14:27:54
【问题描述】:
在我的一个基于 ASP.Net 和 Sitecore CMS 的页面中,我正在使用 CheckBoxList 控件,但不知何故它没有在 HTML 中输出标签。
<asp:CheckBoxList runat="server" ID="chkListBrochure" CssClass="checkbox_single" />
在代码隐藏文件中,我正在加载列表:
foreach (var item in itemList)
{
var newListItem = new ListItem(item.Title, item.Code);
newListItem.Selected = item.Selected;
chkListBrochure.Items.Add(newListItem);
}
当我在浏览器中查看代码时,它显示为
<div id="body_0_content_0_content_1_chkListBrochure" class="checkbox_single">
<input id="body_0_content_0_content_1_chkListBrochure_0" class="" type="checkbox"
name="body_0$content_0$content_1$chkListBrochure$0">
<input id="body_0_content_0_content_1_chkListBrochure_1" class="" type="checkbox"
checked="checked" name="body_0$content_0$content_1$chkListBrochure$1">
<input id="body_0_content_0_content_1_chkListBrochure_2" class="" type="checkbox"
name="body_0$content_0$content_1$chkListBrochure$2">
<input id="body_0_content_0_content_1_chkListBrochure_3" class="" type="checkbox"
checked="checked" name="body_0$content_0$content_1$chkListBrochure$3">
<input id="body_0_content_0_content_1_chkListBrochure_4" class="" type="checkbox"
name="body_0$content_0$content_1$chkListBrochure$4">
<input id="body_0_content_0_content_1_chkListBrochure_5" class="" type="checkbox"
checked="checked" name="body_0$content_0$content_1$chkListBrochure$5">
</div>
如果我将此代码复制到非基于 Sitecore 的项目中,它可以正常工作。有没有人遇到过这个问题?有什么建议吗?
谢谢
纳斯
【问题讨论】:
-
我认为我们需要更多信息。 Var 数据类型是 itemList,item.Selected 和 item.Code 是什么?它们是您为获取字段值而制作的扩展方法吗? item.Id 工作吗
标签: asp.net sitecore checkboxlist