当从c#代码格式化时,Html标签显示在页面中

时间:2012-03-15 19:31:09

标签: c# asp.net html string-formatting

我正在尝试格式化字符串以在c#中的字符串之间添加空格。

summary.AppendFormat("&nbsp;&nbsp;&nbsp;{0}&nbsp;{1}:&nbsp;{2}{3}</br> ", item.FirstName, item.LastName, item.Completed ? item.Summary : "not&nbsp;completed", item.Schedule == DateTime.MinValue ? "" : "&nbsp;(" + DateTime.ToShortDate(item.Schedule, user) + ")");

这应该在HTML页面中呈现为

First Round Suri Narayanan:推荐(2012年3月2日)

但我在html页面中看到如下所示

 First Round</br> &nbsp;&nbsp;&nbsp;Suri&nbsp;Narayanan:&nbsp;recommend &nbsp;(3/2/2012)</br>

如果我使用firebug进行编辑,请说如果我放了一些空间,那么它的格式就会很好。

请告诉我你对此的评论。

1 个答案:

答案 0 :(得分:0)

您应该像下面一样使用Literal。

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

Literal.text =“你的文字”

相关问题