Wednesday, April 25, 2007

Saving line break in multiline textbox ASP.NET 1.1

Many time it happens with the multi line text box that it does not save the line break and another things in the text box. I have found a great way to do this..

You can replace the line break with the string replace function for example your text box name

if you want to assign text box to a some value...
txtAddress.Text=objAddress.CompanyAddress.Replace("put here br","\r\n");

if you want to assign text box value to another object
txtAddress.Text=objAddress.CompanyAddress.Replace("put here br","\r\n");

happy programming...


  1. Nice succinct post :) I was just looking into how to solve this problem with my site. Wasn't sure what the linebreak characters would be when you extract it from the textbox.

  2. thank you for your hint,

    however, i had tried your hint and i wrote the following:
    txtDiagnosis.Text = text.Replace("'\r'", "
    txtDiagnosis.Text = text.Replace("'\n'", "
    txtDiagnosis.Text = text.Replace("\n", "
    txtDiagnosis.Text = text.Replace("\r", "
    txtDiagnosis.Text = text.Replace("\r\n", "
    txtDiagnosis.Text = text.Replace("
    ", "\r\n")
    txtDiagnosis.Text = text.Replace("br", "\r\n")

    and non of those lines had works successfully

  3. nice tutorial
    highly appreciated


Your feedback is very important to me. Please provide your feedback via putting comments.

About Me
My Photo

Full Stack Developer,Blogger,Microsoft Mvp, Mentor, Life long learner, 10+ Years of Experience for JavaScript, web and Microsoft technologies. ASP.NET MVC,Web Forms,C#,AngularJs,Golang
Mvp profile
Subscribe to my blog

Enter your email address:

Follow us on facebook
Blog Archive
Total Pageviews