Recognize and use spaces in multiline textbox

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2009
Posts: 38
Reputation: thacravedawg is an unknown quantity at this point 
Solved Threads: 0
thacravedawg thacravedawg is offline Offline
Light Poster

Recognize and use spaces in multiline textbox

 
0
  #1
Jun 5th, 2009
Okay so I have a multiline textbox that accepts user input and stores it in a database. I then have another form that queries for this field and displays it. Everything is working fine, except for the fact that it won't recognize new lines when the user presses enter. I am at a loss.

I need the form to in some way, accept enter to create a new line and output it from the database with the line breaks the way the user inputs them.

This is aspx with sqlserver if it matters.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: Recognize and use spaces in multiline textbox

 
1
  #2
Jun 5th, 2009
if this is aspx why didnt you post it there?
you have to replace newline characters with <br /> so it displays properly. i created a sample application, i attach it to this post :

Default.aspx :


  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" >
  6. <head runat="server">
  7. <title>Untitled Page</title>
  8. </head>
  9. <body>
  10. <form id="form1" runat="server">
  11. <div>
  12. <asp:TextBox ID="TextBox1" runat="server" Height="89px" TextMode="MultiLine"></asp:TextBox>
  13. <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
  14. </form>
  15. </body>
  16. </html>

Default.aspx.cs :

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10.  
  11. public partial class _Default : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15.  
  16. }
  17. protected void Button1_Click(object sender, EventArgs e)
  18. {
  19. Response.Write( TextBox1.Text.Replace(Environment.NewLine, "<br />"));
  20. }
  21. }
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: Recognize and use spaces in multiline textbox

 
0
  #3
Jun 5th, 2009
i couldnt attach the project to the previous post so here it is
Attached Files
File Type: zip WebSite1.zip (996 Bytes, 3 views)
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC