我有一个ASP.NET中继器从数据库中提取评论数据。
在我的ItemTemplate中,我放置了一些绑定到字段( poster、date和post text的用户名)的Label服务器控件,但是在显示数据之前,Label显然不会通过HtmlEncode运行数据。
有没有其他我应该使用的控件?如何显示来自中继器的HTML编码数据?
发布于 2010-12-23 05:08:47
使用mode="encode“的文本又如何呢?
<asp:Literal ID="Literal1" runat="server" Mode="Encode" />发布于 2010-12-23 05:08:44
可以使用具有模式属性的文本控件,该属性具有枚举Encode、PassThrough和Transform。
发布于 2011-05-03 09:00:40
这对我很有效:
<%# Server.HtmlDecode(DataBinder.Eval(Container.DataItem, "ItemName")) %>https://stackoverflow.com/questions/4513644
复制相似问题