如何获取 Sql 列值并将 html 转换为 asp 标签

How to take a Sql column value and translate the html into a asp label

Sql 列值(从 InfoPath RTF 控件生成):

<strong xmlns="http://www.w3.org/1999/xhtml"><font color="#7030a0">This</font></strong> is a <font xmlns="http://www.w3.org/1999/xhtml" color="#ff0000"><strong>richtextfield</strong></font>

我在 asp.net 中有一个标签:

<asp:Label ID="lblOne" runat="server" Text=""></asp:Label>

如何转换列值以在 asp 标签中显示输出。

示例:

The asp label above would display: `this (in bold and in color) is a richtextfield(in bold and in color)`

使用 Literal 值可能会更好,因为您使用的是原始 HTML.

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.literal.mode(v=vs.110).aspx

<asp:Literal ID="Literal1" runat="server" Mode="PassThrough"></asp:Literal>

在代码隐藏中

Literal1.Text = yourSQLValue;

不过,您应该考虑不要将 HTML 直接放入您的页面。