How to put a HTML paragraph on a WebForm

A

ad

I want to put a HTML paragraph on a WebForm in program.
There are HTML tags in the paragraph, I hope the paragraph can render as
normal HTML page.

Which control can I use to place the HTML paragraph?
 
A

ad

Thanks,
The lines of my HTML paragraph is over 300 lines.
But I found the Literal Control can only acept one line.
How can I put the 300 lines HTML paragraph into a Literal Control ?
 
H

Hans Kesting

Thanks,
The lines of my HTML paragraph is over 300 lines.
But I found the Literal Control can only acept one line.
How can I put the 300 lines HTML paragraph into a Literal Control ?

You don't add the text line-by-line, but first you collect all lines
and THEN assign that (single) string to the .Text property of that
Literal.

string s = "line 1<br>";
s = s + "line 2<br>";
myLit.Text = s;


Note: you will need <br>'s to signal the end-of-line, as this text is
"literal html text", meaning that no translation will be done.

Note 2: if you are adding lots of little strings to build the final
result, you might want to consider using StringBuilder

Hans Kesting
 
U

UT-BadBoy

If your text already contains the endline markers ("\n"), use the
string.replace to replace the "\\n" with the "<br>"

if text is the input(the 300 lines of text with the endline markers)
then

Literal lit = new Liter();
lit.Text = input.Replace("\\n", "<br>");

this should return a HTML friendly text separated into lines.

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top