Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > multiple lines in a label

Reply
Thread Tools

multiple lines in a label

 
 
tshad
Guest
Posts: n/a
 
      01-12-2005
I have a textbox that I am storing as text (or as a varChar). The field has
multiple lines in it (not wrapped).

When I read it back into a multiline textbox, it works fine. But when I
read it back into a label, it shows all lines together.

Is there a way to get the Label to display the lines separately?

I could use textbox and get rid of the border and set enable to false, but
then it greys the text, which I don't want.

Thanks,

Tom.


 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      01-12-2005
Tom,
Remember, line-breaks from a text box or text area are not the same
thing as an HTML line break. Basically you'll need to replace the linefeed
characters in the text box with the HTML <br>. This is a fairly
straightforward operation using the Replace() method of the string
functionality in .Net, such as
varChar.ToString().Replace(Environment.NewLine,"<b r>")

Hope this helps,
Mark Fitzpatrick
Microsoft MVP- FrontPage

"tshad" <(E-Mail Removed)> wrote in message
news:OQB39eO%(E-Mail Removed)...
>I have a textbox that I am storing as text (or as a varChar). The field
>has multiple lines in it (not wrapped).
>
> When I read it back into a multiline textbox, it works fine. But when I
> read it back into a label, it shows all lines together.
>
> Is there a way to get the Label to display the lines separately?
>
> I could use textbox and get rid of the border and set enable to false, but
> then it greys the text, which I don't want.
>
> Thanks,
>
> Tom.
>



 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      01-12-2005
"Mark Fitzpatrick" <(E-Mail Removed)> wrote in message
news:u2B6KjO%(E-Mail Removed)...
> Tom,
> Remember, line-breaks from a text box or text area are not the same
> thing as an HTML line break. Basically you'll need to replace the linefeed
> characters in the text box with the HTML <br>. This is a fairly
> straightforward operation using the Replace() method of the string
> functionality in .Net, such as
> varChar.ToString().Replace(Environment.NewLine,"<b r>")


Does this replace all Newlines?

Also, do I need to move the data to string or can I do it directly from
either my label control or data coming from my dataset, such as:

if not (ClientReader("achievements") is DBNull.Value) then
achievements.text = ClientReader("achievements")
achievements.ToString().replace(environment.newlin e,"<br>") ->
doesn't seem to work here
end if

or can I do it directly in the ClientReader line above?

Thanks,

Tom.

>
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP- FrontPage
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:OQB39eO%(E-Mail Removed)...
>>I have a textbox that I am storing as text (or as a varChar). The field
>>has multiple lines in it (not wrapped).
>>
>> When I read it back into a multiline textbox, it works fine. But when I
>> read it back into a label, it shows all lines together.
>>
>> Is there a way to get the Label to display the lines separately?
>>
>> I could use textbox and get rid of the border and set enable to false,
>> but then it greys the text, which I don't want.
>>
>> Thanks,
>>
>> Tom.
>>

>
>



 
Reply With Quote
 
tshad
Guest
Posts: n/a
 
      01-12-2005
"MWells" <outbound__at_sygnal.com> wrote in message
news:ebu%231kP%(E-Mail Removed)...
> if not (ClientReader("achievements") is DBNull.Value) then
> achievements.text =
> ClientReader("achievements").ToString().replace(en vironment.newline,"<br>")
> end if
>
> -or-
>
> if not (ClientReader("achievements") is DBNull.Value) then
> achievements.text = ClientReader("achievements")
> achievements.text =
> achievements.text.ToString().replace(environment.n ewline,"<br>")
> end if
>


Thanks - that really helps,

Tom
>
>
> "tshad" <(E-Mail Removed)> wrote in message
> news:eRPirDP#(E-Mail Removed)...
>> "Mark Fitzpatrick" <(E-Mail Removed)> wrote in message
>> news:u2B6KjO%(E-Mail Removed)...
>> > Tom,
>> > Remember, line-breaks from a text box or text area are not the

> same
>> > thing as an HTML line break. Basically you'll need to replace the

> linefeed
>> > characters in the text box with the HTML <br>. This is a fairly
>> > straightforward operation using the Replace() method of the string
>> > functionality in .Net, such as
>> > varChar.ToString().Replace(Environment.NewLine,"<b r>")

>>
>> Does this replace all Newlines?
>>
>> Also, do I need to move the data to string or can I do it directly from
>> either my label control or data coming from my dataset, such as:
>>
>> if not (ClientReader("achievements") is DBNull.Value) then
>> achievements.text = ClientReader("achievements")
>> achievements.ToString().replace(environment.newlin e,"<br>") ->
>> doesn't seem to work here
>> end if
>>
>> or can I do it directly in the ClientReader line above?
>>
>> Thanks,
>>
>> Tom.
>>
>> >
>> > Hope this helps,
>> > Mark Fitzpatrick
>> > Microsoft MVP- FrontPage
>> >
>> > "tshad" <(E-Mail Removed)> wrote in message
>> > news:OQB39eO%(E-Mail Removed)...
>> >>I have a textbox that I am storing as text (or as a varChar). The
>> >>field
>> >>has multiple lines in it (not wrapped).
>> >>
>> >> When I read it back into a multiline textbox, it works fine. But when

> I
>> >> read it back into a label, it shows all lines together.
>> >>
>> >> Is there a way to get the Label to display the lines separately?
>> >>
>> >> I could use textbox and get rid of the border and set enable to false,
>> >> but then it greys the text, which I don't want.
>> >>
>> >> Thanks,
>> >>
>> >> Tom.
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
MWells
Guest
Posts: n/a
 
      01-12-2005
if not (ClientReader("achievements") is DBNull.Value) then
achievements.text =
ClientReader("achievements").ToString().replace(en vironment.newline,"<br>")
end if

-or-

if not (ClientReader("achievements") is DBNull.Value) then
achievements.text = ClientReader("achievements")
achievements.text =
achievements.text.ToString().replace(environment.n ewline,"<br>")
end if



"tshad" <(E-Mail Removed)> wrote in message
news:eRPirDP#(E-Mail Removed)...
> "Mark Fitzpatrick" <(E-Mail Removed)> wrote in message
> news:u2B6KjO%(E-Mail Removed)...
> > Tom,
> > Remember, line-breaks from a text box or text area are not the

same
> > thing as an HTML line break. Basically you'll need to replace the

linefeed
> > characters in the text box with the HTML <br>. This is a fairly
> > straightforward operation using the Replace() method of the string
> > functionality in .Net, such as
> > varChar.ToString().Replace(Environment.NewLine,"<b r>")

>
> Does this replace all Newlines?
>
> Also, do I need to move the data to string or can I do it directly from
> either my label control or data coming from my dataset, such as:
>
> if not (ClientReader("achievements") is DBNull.Value) then
> achievements.text = ClientReader("achievements")
> achievements.ToString().replace(environment.newlin e,"<br>") ->
> doesn't seem to work here
> end if
>
> or can I do it directly in the ClientReader line above?
>
> Thanks,
>
> Tom.
>
> >
> > Hope this helps,
> > Mark Fitzpatrick
> > Microsoft MVP- FrontPage
> >
> > "tshad" <(E-Mail Removed)> wrote in message
> > news:OQB39eO%(E-Mail Removed)...
> >>I have a textbox that I am storing as text (or as a varChar). The field
> >>has multiple lines in it (not wrapped).
> >>
> >> When I read it back into a multiline textbox, it works fine. But when

I
> >> read it back into a label, it shows all lines together.
> >>
> >> Is there a way to get the Label to display the lines separately?
> >>
> >> I could use textbox and get rid of the border and set enable to false,
> >> but then it greys the text, which I don't want.
> >>
> >> Thanks,
> >>
> >> Tom.
> >>

> >
> >

>
>



 
Reply With Quote
 
Divya Divya is offline
Junior Member
Join Date: Jan 2010
Posts: 1
 
      01-14-2010
Hi
It helps me alot
Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preserve blank lines when add multiple lines of text to a cell Cah Sableng Javascript 0 04-23-2007 04:46 AM
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner ASP .Net 0 04-09-2007 09:00 PM
How to get/read Hard disk label / drive label Praveen Python 1 11-05-2006 07:48 PM
<label><div></div></label> allowed? Josef K. ASP .Net 3 05-22-2005 02:13 PM
label versus asp:label Question. Thanks. Shapper ASP .Net 2 05-07-2005 05:55 AM



Advertisments