multiple lines in a label

T

tshad

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.
 
M

Mark Fitzpatrick

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,"<br>")

Hope this helps,
Mark Fitzpatrick
Microsoft MVP- FrontPage
 
T

tshad

Mark Fitzpatrick said:
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,"<br>")

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.newline,"<br>") ->
doesn't seem to work here
end if

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

Thanks,

Tom.
 
T

tshad

MWells said:
if not (ClientReader("achievements") is DBNull.Value) then
achievements.text =
ClientReader("achievements").ToString().replace(environment.newline,"<br>")
end if

-or-

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

Thanks - that really helps,

Tom
 
M

MWells

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

-or-

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top