Active Server Pages Programming (ASP)/convert "\n" to <BR>

Advertisement


Question
I have an ASP textbox on my homepage: <asp:textbox id="txtBody" runat="server" TextMode="MultiLine" Columns="40" Rows="10" />.  For large, decriptive text messages, how would I convert a carriage return (like "\n" or vbCrLf) to <br> for an HTML emailer?

If it helps, I am writing this in C#. What would I search for in the textbox? What tools are available in ASP to search this field?

Thanks,
Joe

Answer
Hi

Can you use a Rich Text Editor Tool? User can edit and see the result and it saves as a HTML tags no converstion required

If you need a replace use this function

public static String Replace(String strText,String strFind,String
strReplace)
 {
   int iPos=strText.IndexOf(strFind);
   String strReturn="";
   while(iPos!=-1)
   {
     strReturn+=strText.Substring(0,iPos) + strReplace;
     strText=strText.Substring(iPos+strFind.Length);
     iPos=strText.IndexOf(strFind);
   }
   if(strText.Length>0)
     strReturn+=strText;
   return strReturn;
 }
}

Happy Programming!

-Srini

Active Server Pages Programming (ASP)

All Answers


Answers by Expert:


Ask Experts

Volunteer


Srini Nagarajan

Expertise

I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase

Experience

Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.

©2012 About.com, a part of The New York Times Company. All rights reserved.