tags:

views:

100

answers:

1

Is float really missing from HtmlTextWriterStyle?

I rarely use

Control.Style.Add(HtmlTextWriterStyle.Whatever, "myval");

to set styles for elements, but occasionally I have to create a dynamic element from code-behind and I'll throw in a style via this method, to test out some styling.

Today, I tried to set

float:left;

and was fairly stunned that it doesn't appear to have a float property. I couldn't find much on Google except for this brief log of the issue: Microsoft Connect Log of Error.

So my question is this: Is it really missing and why?

EDIT

So I followed up with @Thomas Levesque's answer and found that the HtmlTextWriterStyle enumeration was introduced on April 3rd, 2003 in .Net 1.1. This was a time when IE 6 was the latest and greatest that MS had to offer. It is possible that due to their shoddy standards, they were still relying on table based layouts.

I don't have any proof that this is the truth, but it's my favorite answer so far.

+4  A: 

You can still use the other Add overload :

control.Style.Add("float", "left");

But indeed it's weird that it's not in the HtmlTextWriterStyle enumeration... probably because Internet Explorer wasn't able to render it correctly at the time this enumeration was created ;)

Thomas Levesque
True and ideally, i should just use a CSS class defined in a stylesheet, but what I really want to know is why is such an important attribute missing from the HtmlTextWriterSTyle enumeration?
Michael La Voie
+1, I'm going with Thomas' explanation :)
Jeff Sternal
Ooo, I like that additional piece of info. That may well be the answer :D
Michael La Voie