Bruce
Bruce

Reputation: 2203

setting the width of a label control

Using the Label control, the display text is set during runtime from the database. I am trying to control the maximum width of the control, for example max of 100 per line with additional characters rolled over to the next line.

I tried this by setting and also using CSS with no luck:

lbl_Feedback1.Width = 50;

I believe the issue lies with the fact that the text of the label is updated during run time of the application. How to solve this?

Upvotes: 4

Views: 16323

Answers (3)

JM1
JM1

Reputation: 1715

You should be able to use

display:inline-block;

It worked for me.

Upvotes: 0

hakksor
hakksor

Reputation: 1380

Your label must be set to "display: block" in order to set a width. Either set this in the css-file:

label, span {
display: block
}

or using inline style (from code-behind):

lbl_Feedback1.Style["display"] = "block";
lbl_Feedback1.Style["width"] = "100px";

Upvotes: 8

Jesse
Jesse

Reputation: 8393

Have your tried the max-width property? eg: max-width:100px;

Upvotes: 0

Related Questions