[RESOLVED]how 'text area' input control insert /r/n in text

I have text in database that don,t have ‘/r/n’. but when assign this text i text area input control, it make next line(beak) in text area.

please let me know what ‘return carries’ it find in text and add ‘/r/n’ in text.

First time ‘/r/n’ not in text, before put in text area, but after put this in ‘text area’ n save , it save text with ‘/r/n’.

Please let me know your thoughts for the same.

string st = "yourStringText";

st.Replace("/r/n"," ");

First time it not find the ‘/r/n’ into string but after put into text Area it will add ‘/r/n’ automatically.

I don’t know why it so happening.I would like to know how ‘text Area’ add ‘/r/n’ automatically. what carries return it found and replace to it ‘/r/n’.

maybe it’s because you have your <textarea> tag in two lines and your text comes a line after your tag like below:

<textarea>
    some text
</textarea>

I guess you should use your text in front of the tag

<textarea>some text</textarea>

Hi vikas,

Thanks for your post.

vikas227

First time ‘/r/n’ not in text, before put in text area, but after put this in ‘text area’ n save , it save text with ‘/r/n’.

Firstly, you could to debug your code to make sure the string which is retrieved from database does not conatin “rn”.

Secondly, if you need to remove “rn” from text before saving text, you could try the following code.

str.Replace("rn", string.Empty);

Hope it will be helpful to you.

Best Regards,

Fei Han

Problem is that

First time It actually save into database as follows:

‘Flow Notification
To: Investment Officer, Branch Manager
Cc: CEO and COO

{loan} has been written off on {loan.datewrittenoff}. The investment has been labelled as Pending Recovery because the machine has been repossessed or repossession is not required.

First Time when I shown on UI then it shows as:

Flow Notification To: Investment Officer, Branch Manager Cc: CEO and COO {loan} has been written off on {loan.datewrittenoff}. The investment has been labelled as Pending Recovery because the machine has been repossessed or repossession is not required. 

But after edit in text area save again in Db then it shows as :

‘Flow Notification
To: Investment Officer, Branch Manager
Cc: CEO and COO

{loan} has been written off on {loan.datewrittenoff}. The investment has been labelled as Pending Recovery because the machine has been repossessed or repossession is not required.

I am unable to understand how this is happening , why first time it is not showing actual format as it is saved in db and after put in text area and save  it shows into correct format.

How text area correct the content into right format?

Please share your reviews with me.

There are different types of line break that are used.  Things like the textarea and an email message use "rn" to signal a new line.  Html uses "<br/>".  If your text uses rn

HellornWorld

and you put that in a textarea it will look like

Hello
World

If you render that text as html it will look like

Hello World

because html does not see rn as a line break.  If your text was this

Hello<br/>World

then in a textarea it would look like this

Hello<br/>World

as textarea does not see "<br/>" as a line break, but if you rendered that data as html it would look like this

Hello
World

What people tend to do is store rn as line breaks in the database as the majority of systems recognize rn as a line break.  If the text ever needs to be shown as html then you replace rn with "<br/>"

<%= myText.Replace("rn", "<br/>")%>

so that html line-breaks are used.  What you have to do is just pay attention to what line-breaks you are using and when you need to convert one type of line break to another.

(note to pedants, I know about <br> vs <br/>, that rn is c# and vb.net is different, that rn is actually CR LR and applies to windows whereas other OSs use just n yadda yadda yadda, I’m just trying to keep things simple :) )

Thanks for your reply.

but first time text dont have ‘/r/n’ but after edit it have /r/n

Actually this problem happening into classic asp, do u have any idea what ‘carries return’ it wil take first time and how text area convert those carries return to ‘/r/n’.

You’ll just have to go through the code and see if anything alters or creates the line-breaks along the way.  It’s hard to guess without knowing what is going on.  For classic asp it should be a constant called vbCRLF.  sText = Replace(sText, cbCRLF, "<br/>") 
something like that will replace them with html line breaks.

do u have any idea how text area format the text automatically, what he found in text so it proper format it.

Hi vikas227,

As far as I know ,it seems that there is no way to format the text automatically in textarea.

I suggest that you can use replace method  replace special character before show in your page.

Best Regards,

Kevin Shen.

Leave a Reply