setting the width of a label control

14,228

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";
Share:
14,228
Bruce
Author by

Bruce

Updated on June 07, 2022

Comments

  • Bruce
    Bruce about 2 years

    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?

  • hakksor
    hakksor almost 13 years
    Hmm.. It really should work. Maybe you have a container with a fixed width. What happens with the exess text? Does it just disappear? Could you post the resulting HTML and/or a screenshot?