1

我有一个格式化文本,其中包含在消息中实现的粗体、斜体和其他样式。我将此消息存储在数据库中。现在我想在 DataList 的字段中实现这些标签。我该怎么做?

不工作。它只是这样显示标签。有什么帮助吗?

4

1 回答 1

0

如果您的意思是您的“消息”包含格式化的 HTML,您应该在 DataBinder 评估“消息”属性的值之后简单地对其进行 HTMLDecode。例如:

' "message" contains the string "<b>Hello World!</b>"
' Within the DataList:
<ItemTemplate>
  <asp:Label ID="lbl1" runat="server" Text='<%# Server.HtmlDecode(Eval("message").ToString()) %>' />
</ItemTemplate>
于 2009-04-11T09:04:59.253 回答