Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6164155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:56:43+00:00 2026-05-23T21:56:43+00:00

I have created a custom server control that inherits from CompositeControl. In the CreateChildControls

  • 0

I have created a custom server control that inherits from CompositeControl. In the CreateChildControls method, I add an input and a label control (there are others, too) to the control tree. I have overridden the Enabled property so that I only get/set the input’s Enabled property, not the composite control’s Enabled property. In the user control where I use this server control, I add Enabled="false" to the markup. However, no matter what I do, the container div gets a disabled="disabled" attribute added to it (and so do some of the children).

Of course, this seems to work just fine in all browsers except IE 6. If there’s a fieldset legend or a radio button list inside the disabled control, the text disappears. I was originally trying to see if there was some defect to fix via CSS for IE 6. Then, I noticed the disabled="disabled" on tags I didn’t even think were valid to have that attribute.

What exactly am I doing wrong here?

Sample control that exhibits behavior:

public class TextBoxWithLabel : CompositeControl
{
    private readonly Label _label = new Label();
    private readonly TextBox _textBox = new TextBox();

    protected override HtmlTextWriterTag TagKey
    {
        get { return HtmlTextWriterTag.Div; }
    }

    public string LabelText
    {
        get { return _label.Text; }
        set { _label.Text = value; }
    }

    public override bool Enabled
    {
        get { return _textBox.Enabled; }
        set { _textBox.Enabled = value; }
    }

    protected override void CreateChildControls()
    {
        _label.ID = ID + "_label";
        _textBox.ID = ID + "_field";
        _label.AssociatedControlID = _label.ID;

        Controls.Add(_label);
        Controls.Add(_textBox);
    }
}

Usage:

<test:TextBoxWithLabel id="tester" runat="server" LabelText="My TextBox" Enabled="false" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:56:44+00:00Added an answer on May 23, 2026 at 9:56 pm

    I have solved this by creating a “new” Enabled property instead of overriding.

    public new bool Enabled
    {
        get { return _textBox.Enabled; }
        set { _textBox.Enabled = value; }
    }
    

    I won’t accept this answer unless I get up-votes from others verifying my finding for the need to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom control that inherits from .NET's CompositeControl class. This control overrides
I have created a custom Server control that processes some data, stores that data
I created a simple custom control that only inherits from the Literal control, and
I have created a custom server control, deriving from System.Web.Contols.CheckBoxList to customize how a
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I have a my own custom web server control. I created separate CSS file
Aloha, I have a custom control that I need to instantiate from within a
I have created a custom control which uploaded files to the server . These
I have a custom server control (composite control having dynamically created dropdown boxes and
I have created a simple Asp.Net custom control which automatically combines all the correct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.