0

This question is for when user is actually typing the text in textarea and not for how to process it afterwards.

When I enter text in textarea and press Enter, and then do a "view source" I see newlines are translated to html paragraphs (<p> and </p>). This causes a big gap between two successive lines. Is there some way of forcing it to use line breaks (<br />)? I tried using CSS but nothing worked (neither it seems I can change font size and type!)

For storing this data in DB, I can replace all <p> with empty string and all </p> with <br /> before processing it so it would display correctly later.

Update I am using an Ajax HTML Text Editor:

<asp:TextBox runat="server" ID="edComment" TextMode="MultiLine" CssClass="Comment" />
<ajaxToolkit:HtmlEditorExtender runat="server" ID="heeComment" 
    TargetControlID="edComment" 
    EnableSanitization="false" 
    BehaviorID="heeComment" 
    DisplayPreviewTab="false" 
    DisplaySourceTab="false">
</ajaxToolkit:HtmlEditorExtender>

When I enter "blah<enter>blah<enter><enter>" and in code behind capture the text (i.e. edComment.Text), I see:

<p>blah</p><p>blah</p><p><br></p>

This is why when I (user), am typing the text, there is such a big gap between two blahs; because they are taken as paragraphs. I am wondering if his can be forced to use <br /> so I would have blah<br />blah<br />. Not after all is said and done but while I am typing the text.

NoBullMan
  • 2,032
  • 5
  • 40
  • 93
  • Can you elaborate a little? Using Google Chrome I don't see any paragraph tags when I view the source after writing in a ` – Daniel Jul 11 '17 at 18:49
  • I think you are talking about a HTML text editor (like CKEditor), and not a textarea. Usually you can press `shift` + `enter` to create a line break. But most editor have the option to change the enter behaviour from `

    ` to `
    ` in a config file.

    – VDWWD Jul 11 '17 at 19:06
  • I updated my post with more info. – NoBullMan Jul 11 '17 at 19:55

1 Answers1

0

If I understand your question correctly, your answer is here:

New line in text area

In short: use & # 13 ; & # 10 ; without spaces to create a new line. Example code would help with clarity in the future!

Allball103
  • 131
  • 8