CSS Style In Web Controls

I was assigning out some MSDN bugs this afternoon when I came across an interesting one.  I enjoy reading the MSDN feedback bugs, there are some in there that we've argued about for months, there are new bugs, and there are some that we just don't quite understand what the bug is about. 

This afternoons interesting bug was someone who wanted to have the text in his ASP:TextBox centered instead of left justified.  Well, the bug was resolved this morning as by design, along with the comment that this was not possible to do due to HTML limitations.  I was pretty sure I'd seen it done before, so I popped over to my dev box and gave it a try, first with an html text box.  And I managed to get this: PPP

Knowing that I could get it to work in HTML, I figured I would try an ASP control.  Sure enough, I pasted the style="vertical-align: middle; text-align: center;" into the control, and bamo, it worked as expected.  But then I noticed something else, you don't get intellisense on style for some ASP control.  So if you try to type "style" in to an ASP:TextBox, you don't get intellisense until after you hit "=" and then you get it. 

I've updated the bug with the code for this guy, so hopefully this'll get him going.  As long as the message pump doesn't take too long to get it from ProductStudio out to the web site!

EDIT: Several of you have pointed out that the text is centered but not middle'ed. So that may not be possible.

Comments (3)

  1. Keith Farmer says:

    The test looks horizontally centered, but not vertically, using IE6.

  2. Ken says:

    The test looks horizontally centered, but not vertically, using firefox 1.0.4 and netscape 7.1 too.

  3. Björn Graf says:

    The spec defines vertical-align: middle; to apply to table cells only, which the more standard following rendering engines follow :]

Skip to main content