CheckBoxList不输出标签
在我的基于 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 的项目中复制此代码,则效果很好。有人遇到过这个问题吗?有什么建议吗?
谢谢纳斯
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就其价值而言,CheckBoxList 在我的 Sitecore 6.5 机器上渲染得很好。
CheckBoxList 的输出不是标准的。默认的 标记上的
asp:CheckBoxList
控件在table
而非div
中呈现复选框。即使您更改RepeatLayout="Flow"
,您仍然不会获得div
;在我的测试中,我得到了一个span
。我想你有一个控制适配器,或者其他东西,可以修改输出。
For what it's worth, a CheckBoxList renders just fine on my Sitecore 6.5 box.
The output of your CheckBoxList is not standard. The default
asp:CheckBoxList
control renders the checkboxes in atable
not adiv
. Even if you changeRepeatLayout="Flow"
on your<ASP:CheckBoxList
tag you would still not get adiv
; on my testing I got aspan
.I would image you have a control adapter, or something, modifying the output.
System.Web.UI.WebControls
中有一个ListItem
控件,但Sitecore.Web 中也有一个名为
。您的代码中是否存在一些关于您所指的代码的混乱?ListItem
的 Sitecore 控件.UI.HtmlControlsThere is a
ListItem
control inSystem.Web.UI.WebControls
but also there is a Sitecore control calledListItem
inSitecore.Web.UI.HtmlControls
. Could there be some confusion in your code as to which one you are referring to ?