.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Reading MultiLine TextBox line by line

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :ASP.Net
If I have a list of something in a MultiLine TextBox, one item per line, how do I then in turn read this? Right now TextBox.Text reads it all as one line. Lets say we have this: TextBox txtbx; At first I thought I could split the string on Environment.Newline, this doesn't work.  Error.Next I thought I could Replace(Environment.Newline,";").Split(";"); This didn't work either, Error.  Both gave cannot convert string to char[] exceptions. What I want to be able to do is read the input line by line and do something with each item one by one. Does anyone know how to do this?Thanks.

View Complete Post

More Related Resource Links

How Do I display only the last line of a Multiline TextBox when rows=1?


hi all,

This is the current code I am using:

                      <asp:TextBox ID="txtBoxComments" runat="server" MaxLength="5000" ReadOnly="true" Rows="1" Text='<%# Eval("Comments") %>'
                       TextMode="MultiLine" Width="100%" Wrap="true" />

 Thank you!


Trying to display only the last line of a Multiline TextBox


Hi all,

On my Asp.Net GridView I am binding a textbox to a field in SQL. Sometimes the content of the textbox is more than 1 line and I
need to show only the LAST line. How can I do that? Here is part of my code...notice that I use Rows=1 on purpose so that
I am able to show only 1 line but I need it to scroll all the way down and have it show only the last line of the whole content:

  <asp:TextBox ID="txtBoxComments" runat="server" MaxLength="5000" ReadOnly="true" Rows="1" Text='<%# Eval("Comments") %>'
      TextMode="MultiLine" Width="100%" Wrap="true" />

 Thank you!

Is textbox the only control with a multi-line option?

I was trying to use a label control to print out a string with spaces and line feeds, but with no success. Textbox is the only control I have found so far that will print my line feeds (ControlChars.Lf)  However, can I remove the scrollbar from the textbox display that appears when textboxmode is set to multiline? -smc

Read a multilined textBox line by line

Hi, I am trying to read a multilined textBox line by line into a List<String> but with the code below the compiler says that "'System.Environment' does not contain a definition for 'Newline' String getLine = ""; List<String> getLines = new List<String>(); string[] mylines = TextBox6.Text.Split(Environment.Newline); for (int i = 0; i < mylines.Length; i++) { getLine = mylines[i].ToString(); getLines.Add(getLine); }  

Removing first line/getting TextRange from TextBox



I have a plain TextBox and I need to remove the first line in it. Better than setting the Text property with whole new content I thought I would get a TextRange containing the first line and set its Text to empty string, but I cannot figure out how to get TextPointers from the TextBox.

Any idea how to get it or other way to do it?


regarding display textbox and image in same line using ajax ...


iam uing ajax to check availblity of username from sql. evrythng is working fine ...only the thing is the image i want to dispaly aftr the text using:http://encosia.com/2007/07/02/aspnet-username-availability-checking-via-ajax/ but how to display images aftr the text box...it displays in next line ..please can u help me ..how to display images next to texbox...

How to input line breaks and formating in textbox with multilines ?


I have a web form in which anyone can fill out the information and i recieve the information.

<asp:TextBox ID="Body" runat="server" Columns="55" Height="101px" Rows="30" TextMode="MultiLine"

The problem is while entering the information in this text box, if anyone used enter line or different line or any kind of formatting, as a result i don't get the formatted page or with lines. I see only a paragraph which is very difficult to read and understand.

How to make my textbox compatible with all kind of formatting options so that even if someone paste information from word etc in the text box , i should get the formatter information just like the user pasted the information in the text box...

How do I make it so when I user pressing return, it goes to the next line in a textbox?

I've got a textbox control on a WPF 4.0 app I've written.  This control allows for multiple lines, and that works fine.  However, my users like to be able to type something, hit the enter/return key which they're used to having it go to the next line in the textbox, where they then continue typing whatever it is they want to type.  Well, it's not doing that.  How do I make it do that?

How to speed up Reading Text File line by line?


Hi all,

The following is my problem which need to be solved:


I have text file like this:

id=1, name=smith, age=22, address=London;

id=2, name=john, age=30, address=Roma;

id=3, name=Pen, age=19, weight=60, address=Paris;

id=4, name=Ajay, age=44, address=India;


using vb, I succeeded to convert it to a table format like this


id      name        age       weight      address

1      smith          22           null         London

2      john            30          null          Roma

3      pen             19           60           Paris

4      Ajay            44           null          India


I used StreamReader for that.

someone may still ask: Ok Adel so where is your problem? kindly read the following lines

In fact, my only problem is related to the time it takes if the number of rows is 70,000

How can I stop CR from being removed when a multi-line textbox in a section is within another sectio



I have a multi-line text box that sits in an optional section. This optional section is within another optional section. When it is displayed it has CR removed. I know that it does work when there is only one encompassing section.

Does anyone know how to stop this happening? Any clever little tricks...;)

Actually - just tested again and I can get it to work sometimes i.e. when I first open the form, but then it will remove CR from the mentioned section when another optional section is opened - any ideas???? 



Regex, continue reading the next line if required ending isn't found


Hello :)

Started investigating Regexps yesterday, and got stuck on a little selfmade experiment ^^
It would be the following(discarded the irrelevant code):

Let's assume this text file :

My Fruit information (Fruit (name apple) (size 30 30 30) (color green) (age 10)) (Fruit (name banana) (size 10 60 10) (color yellow) (age 5)) (Fruit (name ...) (size ... ... ...) (color ...) (age ...))

Let's say I want to print for the apple :

 Fruit number 1 is a apple:
 -sizes are 30 30 30
 -It has a green colour
 -It is 10 days old
If the apple information was on the same line it could easely be done with this Regexps:
Regex Fruits = new Regex(@"\(Fruit \(name (.*)\) \(size (.*)\) \(color (.*)\) \(age (.*)\)\)");

But in my case it has some information on the next line aswell.
I can't just search for (color ... ) 'cause it could give me the wrong line.

So how can I make it so , that it won't stop reading untill it finds the "))" (or end of file, in case this could give errors ) no matter how many lines it has to read.

Googled it a bit, but couldn't find a cle

Article commenting by line number


I'm wondering what's the best way to approach an online article system that allows users to comment by clicking on the line they are commenting about? Essentially the same way Adobe Acrobat works with comments where you can click anywhere and the text is saved for that location.

I'm assuming a mix of jQuery would be the crux of the interface. The system would need to save comments so that when another user logs in, they will also see the other comments but they can´t edit them - only add their own.

Any suggestions would be great.

New off line application working with sdf file. Need advice


Hey Folks

I am working on a project currently where I need to get data out of a 3rd party vendor's software that uses a .sdf file I looked this up and its a SQL CE file. I was hoping to just link to with with access but thats apparently not going to happen. I need to link to the database extract data from it to a csv file for later use. I also and most important I need to get the data from it and create a report that can be printed while on a customers site that my or may not have web access so I need for this program to be on and off line. I had my webapplication that I have been working on open and was able to bring up the sdf file under the server exploere however I can't seem to get anything out of it when I try to do grid views or detail views errors out.

Can I use one of Visual Studio projects to create this sort of applicaiton if so what would be the best approach. I would love to get an access odbc driver since office is allready installed on the employee's laptop's



Line Break Problem in XSLT


Hi All,

I want to add line break in the xslt but it not working.

Below is the code for adding the line break.

</P> <P>
&lt;xsl:variable name="Collection7"&gt;</P> <P>&nbsp; &lt;xsl:value-of select="$13932"/&gt;&lt;xsl:text&gt;&amp;#xa;&lt;/xsl:text&gt;</P> <P>&nbsp; &lt;xsl:value-of select="$31042"/&gt;&lt;xsl:text&gt;&amp;#xa;&lt;/xsl:text&gt;</P> <P>&lt;/xsl:variable&gt;</P> <P>&lt;td&gt;&lt;xsl:value-of select="$Collection7"/&gt;&lt;/td&gt; </P> <P>&lt;/code]</P> <P>I have tried the below code as well:</P> <P>&lt;xsl:variable name="newline"&gt;
&lt;/xsl:variable&gt;</P> <P>or</P> <P>&lt;xsl:variable name="break"&gt;&amp;lt;br&amp;gt;&lt;/xsl:variable&gt;</P> <P>or </P> <P>addign &lt;br/&gt;</P> <P>then also it not adding the line break.</P> <P>But If I write code like below then it is adding the line break and it works fine.</P> <P>

crystal report -visual studio 2008 dual axis chart (bar & line)


dear all, 

i use crystal report integrated with  vs.2008, and i want to make chart with dual axis (bar & line).

i have used bar chart and input the data with 2 values..

then in chart options > template, i activated the dual axis..

my question is, how i can change the 2nd value with line chart not bar chart??

i'd tried to find the right settings in "chart options" but still can't find the solution.

for information in "chart options" there are 4 sub menu : template, general,titles,grid..

i read in a tutorial there's more sub menu called "series" in crystal report (stand alone version)..

is it possible doing it in Crystal Report VS. 2008?

please,, i need your advice and solution..

Thanx before..


Extreme UI: Line Charts with Data Templates


Charles Petzold continues his investigation into robust XAML coding made possible by Windows Presentation Foundation, this time tackling the complicated process of creating line charts.

Charles Petzold

MSDN Magazine January 2010

Silverlight: Build Line-Of-Business Enterprise Apps With Silverlight, Part 2


Here we wrap up the call center client application we began last month. The techniques we illustrate will help you build real-world enterprise solutions using Silverlight.

Hanu Kommalapati

MSDN Magazine February 2009

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend