Hi friends ,
In your web application, some times you need to display multi-line formatted text in your txtBox. For example, the string value in your database table is -"r 001,<br/>solved<br/>" , and you have to display that value in your text as follows is the requirement-
r001,
solve
thanks
So you have to replace all the <br/> tags with new line in your database value on the time of retrieving, for that the following method will fulfill the above requirement.
  1. public string ReplaceBRwithNewline(string txtVal)
  2. {
  3. string newText = "";
  4. // Create regular expressions
  5. System.Text.RegularExpressions.Regex regex =
  6. new System.Text.RegularExpressions.Regex(@"(<br />|<br/>|</ br>|</br>)");
  7. // Replace new line with <br/> tag
  8. newText = regex.Replace(txtVal, "\r\n");
  9. // Result
  10. return newText;
  11. }
Please give your valuable suggestions and feedback.