Label look like Textbox

T

tshad

I have a screen that is displaying an asp:textbox that has about 20 lines of
text with line feeds that I read out of my Database.

This displays fine as a multiline textbox. It doesn't as a Label. It jams
all the text together into one continuous line of text.

Is there a way to display the data like a textbox, but not look like a text
box? In other words, I don't want the border and I want it to be the same
color as the background of the table. I also want it be selectable, but not
changeable.

At the moment the line looks like:

<asp:TextBox id="jobDescription" TextMode="MultiLine" Columns="50" rows="3"
runat="server" />

How would I change this to display everything (no scrolling)?

Thanks,

Tom.
 
G

Guest

Hi Tom,

If I'm understanding you corrently, what you really want is a label control
that preserves your line formatting?

The simplest way would be to take ur database field from your dataset, and
replace your newline character with a <br>.

In C#, this would look like..

myDS["myfield"].ToString.Replace(replacewhat, "<br>");

where replacewhat is the newline character your using. usually in c# this
will work with either "\n", "\r", etc. If you're using vb, I think the syntax
is

Replace(myDS("myfield"), replacewhat, "<br>") - dont quote me on that, it's
ages since I did some vb!

anyway, hope i got the right end of the stick!

Cheers


dhnriverside
 
T

tshad

Dan Nash said:
Hi Tom,

If I'm understanding you corrently, what you really want is a label
control
that preserves your line formatting?

The simplest way would be to take ur database field from your dataset, and
replace your newline character with a <br>.

In C#, this would look like..

myDS["myfield"].ToString.Replace(replacewhat, "<br>");

where replacewhat is the newline character your using. usually in c# this
will work with either "\n", "\r", etc. If you're using vb, I think the
syntax
is

Replace(myDS("myfield"), replacewhat, "<br>") - dont quote me on that,
it's
ages since I did some vb!

anyway, hope i got the right end of the stick!

Pointed me in the right direction.

Here is what I ended up with:
********************************************
Dim sResults As String
sResults = PositionReader("JobDescription")
jobDescription.text = sResults.Replace(vbCRLF,"<br>")
**************************************************

Worked great.

Thanks,

Tom
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top