tags:

views:

1119

answers:

4

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 resizes the table and 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 labirynth.

A: 

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).

Dave Markle
A: 

<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.

ceejayoz
As far as I remember asp:label are rendered as "<span>Text</span>", not as "<label>Text</label>".
splattne
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
+1  A: 

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....

Mark Brackett
A: 

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

sandy sears