0

So my problem is : I input something on an asp textarea with a nextline character ( when you press enter and go to the next line ) and save it into my database. When assigning that text into a label, I am getting a straight line text. I want the label to be constructed exactly like how I construct those text or paragraph on my textarea.

Can someone please help me

  • Possible duplicate of [Replace Line Breaks in a String C#](https://stackoverflow.com/questions/238002/replace-line-breaks-in-a-string-c-sharp) – VDWWD Jan 24 '19 at 09:06

3 Answers3

0

Solved. store string into database with string overview. (code tested with database insertion)enter image description here

  • aspx

    <textarea id="TextArea1" runat="server" cols="20" rows="2"></textarea>
    <asp:Button ID="Button1" OnClick="Button1_Click" runat="server" Text="Button" />
    <br /><br />
    
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    
  • C#

    protected void Button1_Click(object sender, EventArgs e) { string overview = TextArea1.InnerText.Replace(Environment.NewLine, "
    "); Label1.Text = overview;
    }

jay sedani
  • 57
  • 9
0

I solved this problem by simply adding a "white-space: pre-wrap" on the css of the textarea and the label i want it to output. I am actually amazed on how fast this question got responded Thanks to those who takes time answering my question! :D

-1

It wold be good option like you replace your textarea with basic text editor that will generate you html code which contains next line as well, save this html data in database, later get that stored html data from database and display wherever you want to display.