如何显示存储在Sql server数据库中的html标签? [英] How can I display html tags stored in Sql server database?
本文介绍了如何显示存储在Sql server数据库中的html标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试显示从SQL Server数据库中检索的html标记,但它正在显示为文本,我希望显示图像并正确格式化其他html标记。这是我的代码:
// C#代码:
I am trying to display html tags that is being retrieved from SQL Server Database, but it is being displayed as text, i want the images to be shown and other html tags properly formatted. Here is my code :
//C# Code:
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[1] { new DataColumn("descriptions", typeof(object)) });
dt.Rows.Add(rssfeedcls.msgError.ToString());
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
// HTML代码:
//HTML Code:
<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<asp:Literal ID="Literal1" runat="server" Text='<%# Eval("descriptions") %>'></asp:Literal><br />
</ItemTemplate>
</asp:Repeater>
我也用过这个:
// C#代码:
I also used this:
// C# Code:
HtmlTableCell block = new HtmlTableCell();
block.InnerHtml = rssfeedcls.msgError.ToString();
HtmlTableRow row = new HtmlTableRow();
row.Cells.Add(block);
tbldescriptions.Rows.Add(row);
// HTML代码:
//HTML Code:
<table runat="server" id="tbldescriptions" cellpadding= "0" cellspacing="0"></table>
请问有谁知道怎么做?在此先感谢...
Please does anyone know how to do this? Thanks in advance...
推荐答案
尝试
http://www.dotnetperls.com/htmlencode-htmldecode [ ^ ]
这篇关于如何显示存储在Sql server数据库中的html标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文