views:

245

answers:

1

I have a container of custom controls each of which have 2 controls in them. One to display when enabled (i.e. a textbox, or checkbox), and a label to display when disabled.

I've overloaded Render like so:

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
        If Me.Enabled Then
            _item.RenderControl(writer)
        Else
            _display_text.RenderControl(writer)
        End If
    End Sub

however, when I set the container, which is a table, to Enabled = False, my expected functionality doesn't happen. Instead I get grayed out textboxes and checkboxes.

What actually happens when you set a parent's Enabled property? My assumption was that it propagated that status down to all its children, but it appears that I'm mistaken.

Thank you!

A: 

Short answer is that your assumption is actually wrong.

If you like (and are extending WebControl, and your container has a runat=server), you could use

If NamingContainer.Enabled Then

instead of

If Me.Enabled Then

but properties do not auto propagate down the the tree in asp.

Matt Briggs
Do you have a long answer? ;) Specifically: what, then, is telling my textboxes, et al. to be disabled?
Wes P