I'm having problem with adding style attributes to the control in my custom web control. Below is a very simple custom web control just to illustrate the problem:
[ParseChildren(true)]
[ToolboxData("<{0}:SomeControl runat=\"server\"></{0}:SomeControl>")]
public class SomeControl : WebControl
{
public CheckBox MyCheckbox { get; set; }
protected override void CreateChildControls()
{
MyCheckbox = new CheckBox { Text = "Here is some text" };
MyCheckbox.Style.Add("some", "style");
Controls.Add(MyCheckbox);
base.CreateChildControls();
}
}
When used on a page I get the following output:
<span><span style="some:style;"><input id="ctl03" type="checkbox" name="ctl03" /><label for="ctl03">Here is some text</label></span></span>
Why is the style attribute on the span tag and not on the input tag?