views:

307

answers:

1

I wrote a custom server control that inherits from CompositeControl. When the control is instantiated, I am dynamically adding a TextBox to its Controls collection. I have overridden the TabIndex property so that when it is set, it applies the value to the TabIndex property of the child TextBox control. The problem is that when the CompositeControl is rendered, it includes a span tag as the overall container, and it is setting the tabindex property on the span as well as the input (TextBox) control. This makes the cursor actually tab to the span, which is not what I want. Any ideas on how to get the CompositeControl to not render the tabindex property on the span?

A: 

I answered my own question. It turns out that the wrapper span tag is not really necessary at all, and you can remove it by simply including the following overrides in the class inheriting from CompositeControl:

public override void RenderBeginTag(HtmlTextWriter writer)
{
    // NOOP
}

public override void RenderEndTag(HtmlTextWriter writer)
{
    // NOOP
}
jeremcc