Take this simple example for example:
<asp:Panel ID="pnlTest" runat="server">
<asp:TextBox ID="txPanelText" Text="Text" runat="server" />
</asp:Panel>
Now, in the codebehind, do this:
pnlTest.Enabled = false;
txPanelText.Enabled = true;
Why does disabling the panel also disable the textbox within it? Furthermore, why does explicitly enabling the textbox have no effect?
This obviously has something to do with the ASP.NET framework. Is there any way I can avoid this?
NOTE: This is not the actual code I am using in my application. It’s just an example to show how disabling a control also recursively disables all child controls within it.
That is by design, and to achieve the effect that you’re looking for you’ll need to use a different approach. I would suggest recursively iterating through the child controls and using some logic to determine which controls get disabled and which don’t.