Display Memo Text

G

Gmansky

I have a dataItem that is a text memo field. When I use
<%#container.DataItem('memoText')%>, it displays it with no line breaks.

Is there a function to convert the line breaks on the memo field?

Thanks,
George
 
S

Simon Harris

You'll need to replace line breaks: &vbcrlf
With line break tag <br>

And vice versa when putting the data into a textarea for editing.

Simon.
 
R

Rick Strahl [MVP]

Hi George,

When you display this in a textbox it should display fine. If you use a label you need to convert the line breaks with <br> or <p> tags. Here's a routine that I use for this:
/// <summary>
/// Fixes a plain text field for display as HTML by replacing carriage returns
/// with the appropriate br and p tags for breaks.
/// </summary>
/// <param name="String Text">Input string</param>
/// <returns>Fixed up string</returns>
public static string DisplayMemo(string HtmlText)
{
HtmlText = HtmlText.Replace("\r\n","\r");
HtmlText = HtmlText.Replace("\n","\r");
HtmlText = HtmlText.Replace("\r\r","<p>");
HtmlText = HtmlText.Replace("\r","<br>");
return HtmlText;
}


+++ Rick --


--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top