0

I don't really FEEL CSS and it doesn't always work as I think it would.

This is one of these situations:

I have a simple (2 rows, 2 columns) asp:table generated dynamically. in the right column it contains a combo box (cell (0, 1)) and a label (cell (1,1)). When I change the combobox's selection, the text in the label changes too. If it's too long for a cell, it re-sizes the table. I would prefer the text to be in lines, so that it fits cell's width.

I don't know if it's some label's property that could do it or should I specify this in CSS style of a label or of a cell? i tried setting table's width explicitly, cell's width in CSS class but nothing works and I feel like a blind in a labyrinth.

4 Answers 4

2

<label> elements can, if you want, be set to display: block; and then given a fixed width via CSS. This may be the best solution for you.

2
  • As far as I remember asp:label are rendered as "<span>Text</span>", not as "<label>Text</label>".
    – splattne
    Dec 27, 2008 at 15:30
  • If you use the AssociatedControlID property, then it renders as a html-label. Otherwise it falls back to a html-span, which in most cases could just have been a simple literal control.
    – Tom Jelen
    Dec 27, 2008 at 16:53
1

Unless you've set white-space to nowrap, your text should be wrapped at spaces. Is the string unbreakable?

A minimal example with URL and/or markup may help....

0

First off, I have to say (as the bitter voice of experience) that if you don't want to really go through CSS and study it to really understand it, this is just the tip of the iceberg in terms of the pain you'll experience in web development.

But more to the point, a quick and dirty solution would be to change your label from being an asp:Label to an asp:Literal. This will cause it to output directly to your HTML page. You should then be able to set your width of the cell explicitly in the table, and your text in the asp:Literal will most likely wrap (depending on the style you're using, of course).

0

I have found that you have to specifically put style="white-space: normal" on the label to make it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.