Reputation: 471
I have a string that's a full HTML document text - it ends with the closing html tag. I need to append text and newline to this htmlText. Sometimes I need to insert a line before the htmlText, sometimes after.
Is it correct to just do stringText + "'<'br/>" + htmlText + "'<'br/>" + moreStringText?
So far, what I tested looked right, but I'm not sure what the correct way to handle this is?
Thanks,
Mike T
Upvotes: 1
Views: 7963
Reputation: 471
I found the solution - using DevEx RichEditDocumentServer interface, I'm using the SubDocument InsertHtml and InsertText methods, and it's working great!
Upvotes: 0
Reputation: 983
Any text that you want to be rendered as part of a webpage needs to be placed inside the <html>
and </html>
tags for it to be valid.
Passing the following
<!doctype html><head><title>Html Page</title></head></html>
My text here
to the W3 HTML validator generates the following error:
Error: Non-space character in page trailer.
From line 3, column 1; to line 3, column 11
></html>↩↩My text here
Also, as slnit says, you should use a StringBuilder instead of using String concatenation.
What text are you wanting to add to the beginning or end of the HTML page?
Upvotes: 1
Reputation: 35
You can use SringBuilder class.
string body = " some text";
StringBuilder buildHtml = new StringBuilder();
buildHtml.Append("<HTML>");
buildHtml.AppendLine(body);
buildHtml.Append("</HTML>");
string sHtml = buildHtml.ToString();
Upvotes: 0