Active Server Pages Programming (ASP)/convert "\n" to <BR>
Expert: Srini Nagarajan - 8/15/2005
QuestionI 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
AnswerHi
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