1

I have a label in my Webform. I want to wrap its text, so that it will automatically linebreak after a particular width in pixels.

The text for the label is coming from the database

        Label lblU = new Label();
       lblU.ID = "LabelU" + i.ToString();
        lblU.Text = ds.Tables[0].Rows[i][0].ToString() + " : ";

There's no property like Autoresize or MaximumWidth, do I need some assembly references or something?

this is the Bug I want to overcome

Jot Dhaliwal
  • 1,470
  • 4
  • 26
  • 47

1 Answers1

1

The Label control renders as a <span> element, so just set its width via a style sheet:

I see that your example text has no white space. In that case, you have to set the word-wrap property to break-word

span {width:5em; word-wrap:break-word}
Community
  • 1
  • 1
mr_plum
  • 2,448
  • 1
  • 18
  • 31