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
I don't want to print the <BR />
tags on the screen. I want them to behave as actual breaks.
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();
If I Html.Encode()
the output of the helper method, the encoded tags - /><
- 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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…