Newline with HTMLEncode in Div and Label

V

versus

Hi

I have a table column that has multiple lines (\r\n) and html tags in it. I
want to display it in a div and label that html tags can be seen and
newlines should work.
If i use div.innerHTML newlines are lost and html tags doesn't show.
If i use div.innerHTML with replace(Environment.NewLine,"<br>") breaks works
but html tags doesn't show.
If i use div.innerText again newlines and html tags are lost.

What can i do?

Thanks
 
V

versus

Thanks for answering. Replace(Environment.NewLine,"<br>") already works for
that problem. But i cannot see html tags as regular text. I want them to be
displayed not parsed with htmlparser.

Let me explain again. I have an sql db table with columns that has both
environment.newline(\r\n) and html tags. I want newlines to break lines and
html tags to be displayed at the same time.
 
L

Lloyd Sheen

versus said:
Thanks for answering. Replace(Environment.NewLine,"<br>") already works
for that problem. But i cannot see html tags as regular text. I want them
to be displayed not parsed with htmlparser.

Let me explain again. I have an sql db table with columns that has both
environment.newline(\r\n) and html tags. I want newlines to break lines
and html tags to be displayed at the same time.

"Peter Bromberg [C# MVP]" <[email protected]>
wrote in message
Versus,
The bottom line is that "\r\n" means nothing in HTML - you have to change
it
to "<br/>" -- which means you need to pre-process your string with
.Replace("\r\n", "<br/>");

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

I think if you use the <pre> tag to wrap your code it will honor the CRLF
and show the tags as if they are text within the <pre></pre> tags.

Hope this helps
LS
 
V

versus

I think if you use the said:
and show the tags as if they are text within the <pre></pre> tags.

Hope this helps
LS

Thanks but his solution removes css classes and when i use checkbox with
label, label click doesn't work.
 
R

Rad [Visual C# MVP]

I

insensus

Thanks for answering. Replace(Environment.NewLine,"<br>") already works
for that problem. But i cannot see html tags as regular text. I want them
to be displayed not parsed with htmlparser.
Let me explain again. I have an sql db table with columns that has both
environment.newline(\r\n) and html tags. I want newlines to break lines
and html tags to be displayed at the same time.
"Peter Bromberg [C# MVP]" <[email protected]>
wrote in message
Versus,
The bottom line is that "\r\n" means nothing in HTML - you have to change
it
to "<br/>" -- which means you need to pre-process your string with
.Replace("\r\n", "<br/>");
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
:
Hi
I have a table column that has multiple lines (\r\n) and html tags in
it. I
want to display it in a div and label that html tags can be seen and
newlines should work.
If i use div.innerHTML newlines are lost and html tags doesn't show.
If i use div.innerHTML with replace(Environment.NewLine,"<br>") breaks
works
but html tags doesn't show.
If i use div.innerText again newlines and html tags are lost.
What can i do?
Thanks

I think if you use the <pre> tag to wrap your code it will honor the CRLF
and show the tags as if they are text within the <pre></pre> tags.

Hope this helps
LS

That's correct but the problem lies elsewhere.
If you update a <pre> tag with innerHTML, Internet Explorer will
remove the \n's before it's in the <pre> tag.
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top