McArthey
McArthey

Reputation: 1646

Possible to make the elements within a UserControl ReadOnly?

I am dynamically loading usercontrols with Page.LoadControl() and would like to selectively make some of the controls display only. These controls are web forms that contain various elements such as textboxes, dropdown lists, etc. Is it possible to do this at the control level or must I disable each of the elements within the control separately? Thanks!

Upvotes: 0

Views: 208

Answers (1)

Adil
Adil

Reputation: 148150

If you can group the control and have to enable or disable group you can use panel for this purpose. You will have to enable or disable panel and all controls in it will be enabled or disabled.

<asp:Panel ID="Panel1" runat="server" Enabled="false">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <asp:RadioButton ID="RadioButton1" runat="server" />
    <asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Panel>

Upvotes: 1

Related Questions