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

  • SEARCH
  • Home
  • 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 6718987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:02:20+00:00 2026-05-26T09:02:20+00:00

My spec calls for a drop down OR two calender boxes along side a

  • 0

My spec calls for a drop down OR two calender boxes along side a radio button group to control which is active, so I made this user control:

<asp:RadioButton 
    GroupName="group1" 
    ID="DateMacroRadioButton" 
    runat="server" 
    Checked="true" />
<uc:DateMacroSelector ID="DateMacroSelector1" runat="server" />
<asp:RadioButton GroupName="group1" 
    ID="CustomDateRadioButton" 
    runat="server" 
    AutoPostBack="true" Text="" />
<uc:DateSelector ID="DateSelector1" runat="server" />
to
<uc:DateSelector ID="DateSelector1" runat="server" />

enter image description here

I’d like enable/disable child controls using groups:

<asp:RadioButton 
    GroupName="group1" 
    ID="DateMacroRadioButton" 
    runat="server"  
    Checked="true" />
<uc:EnableGroup ID="EnableGroup1" runat="server"
   CheckBoxId="DateMacroRadioButton">
   <uc:DateMacroSelector ID="DateMacroSelector1" runat="server" />
</uc:EnableGroup>
<asp:RadioButton GroupName="group1" 
    ID="CustomDateRadioButton" 
    runat="server" 
    AutoPostBack="true" Text="" />
<uc:EnableGroup ID="EnableGroup12 runat="server" 
    CheckBoxId="CustomDateRadioButton">
   <uc:DateSelector ID="DateSelector1" runat="server" />
   to
   <uc:DateSelector ID="DateSelector1" runat="server" />
</uc:EnableGroup>

How might I go about designing the user control that works this way?

  • 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-26T09:02:21+00:00Added an answer on May 26, 2026 at 9:02 am

    You could create a custom control, something like this ought to work (getting the “parsechildren” settings to make it work in the designer is always annoying but I think this is right):

    [ParseChildren(typeof(WebControl), ChildrenAsProperties = true, 
        DefaultProperty = "ChildControls"), NonVisualControl]
    public class EnableGroup: Control
    {
            public EnableGroup() {
                 ChildControls = new Collection<WebControl>();
            }
    
            protected override void OnPreRender(EventArgs e)
            {
                foreach (WebControl ctl in Controls) {
                    ctl.Enabled = this.Enabled;
                }
                base.OnPreRender(e);
            }
    
            public Collection<WebControl> ChildControls
            {
                get; 
                protected set;
            } 
    }
    

    But honestly, it might be just as easy to simply write an extension method or something, e.g.

    public static SetChildEnabled(this WebControl parent) {
        foreach (WebControl ctl in parent.Controls) {
             ctl.Enabled = parent.Enabled;
        }
    }
    

    Then just use any old control to wrap your groups…

    <asp:PlaceHolder runat="server" id="Group1">
    </asp:PlaceHolder>
    

    and call that code on prerender:

    Group1.SetChildEnabled()
    

    You could make either work recursively pretty easily to handle deeper nested children if desired.

    Come to think of it, you could probably just create a control that extends PlaceHolder and skip the hard part above… if you want to be able to control what object types are allowed in your container, that’s how you do it, but may be overkill.

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

Sidebar

Related Questions

I want to be able to spec out that when Open-Uri open() calls either
Consider the following jasmine spec: describe(something.act(), function() { it(calls some function of my module,
I'm working with a spec that calls for a peculiar Datetime format that I
I have a requests spec that makes multiple calls to visit within a single
I am writing a spec for an object (Sample) that calls another object's method
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),
Does the functional spec help or hinder your expectations? Do programmers who practice the
The C# 3.0 spec has the following code example in section 10.6.1.3 Output parameters:
I have a spec in my current project that requires us to advise the
Does anyone here use Spec# regularly? I would like to know if it is

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.