如何使EN codeD标签作为适当的HTML,而不是文字? [英] How to render encoded tags as proper HTML, rather than text?

查看:196
本文介绍了如何使EN codeD标签作为适当的HTML,而不是文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到从数据库以下文字:(由客户提供的,所以我不能做多少吧)

I'm getting the following text from a database: (supplied by client, so I can't do much with it)

investment professionals.<BR /><BR /> blah blah blah

这是越来越呈现为:

which is getting rendered as:

investment professionals.<BR /><BR /> blah blah blah

我不希望打印的&LT; BR /&GT; 在屏幕上的标签。我希望他们能够表现为实际的休息。

I don't want to print the <BR /> tags on the screen. I want them to behave as actual breaks.

下面的HTML帮助code建立它存在于跨度补充说,到一个div并返回HTML字符串:

The following Html Helper code builds the span it exists in, adds that to a div and returns the HTML string:

            StringBuilder sbElements = new StringBuilder();

            TagBuilder span = new TagBuilder("span") {InnerHtml = subject.AboutText};
            sbElements.Append(span.ToString());

            TagBuilder div = new TagBuilder("div");
            div.MergeAttribute("class", "about-text");
            div.InnerHtml = sbElements.ToString();

            return div.ToString();

如果我 Html.En code()辅助方法,将EN codeD标签的输出 - /&放大器; GT;&放大器; LT; - 被写入到屏幕上。我怎样才能把原文我已经和确保标签得到呈现为HTML,而不是文字?

If I Html.Encode() the output of the helper method, the encoded tags - /&gt;&lt; - get written to the screen. How can I take the source text I have and ensure that the tags get rendered as HTML, rather than text?

推荐答案

试试这个:

    String Input = "investment professionals.&lt;BR /&gt;&lt;BR /&gt; blah blah blah";

    String Output = Server.HtmlDecode(Input);

这篇关于如何使EN codeD标签作为适当的HTML,而不是文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆