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 452257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:03:16+00:00 2026-05-12T22:03:16+00:00

currently i’ve built a collapseControl which behaves similar to a label (associatedControlID) to control

  • 0

currently i’ve built a collapseControl which behaves similar to a label (associatedControlID) to control the collapse-state of a control.

following control i’d like to build:

collapsableArea http://img692.imageshack.us/img692/3307/stackoverflowcollapseab.jpg

i thought of something like:
put my already build collapsableControl and some other control (eg. panel) together to get a collapsableArea.

first try:
i tried to extend a panel and did the following:

this.Parent.Controls.Add(collapsableControl);

but this gave me: “not correct life cycle step”, “can’t modify”, “nullReference”, … exceptions

so i gave it another try (which i believe the better choice, due to getting no tagKey):
i extended a placeholder and did the following:

this.Controls.Add(collapsableControl);
this.Controls.Add(collapsablePanel);

this caused other problems, like: i only want to set the text of the panel, the style of the panel, …

wired!

do you have any solutions for this scenario?

edit:
i came up with another solution:
another solution http://img109.imageshack.us/img109/3307/stackoverflowcollapseab.jpg

“CollapsableArea” is of type “Control”, containing 2 extra private properties:

  1. “CollapsableControl”
  2. “Panel”

i thought it would be enough, to redirect the getter of the CollapsableArea.Controls to CollapsableArea.Panel.Controls. in CollapsableArea.CreateChildControls() i instanciate and add the CollapsableControl and Panel to base.Controls and in CollapsableArea.RenderChildren() render those 2

my problems now:
the CollapsableControl will get a clientID (without setting an ID) – the panel won’t
render CollapsableControl will fail (or passed out), if panel contains <% %>-tags

any suggestions?

edit:
i fixed the behaviour of the missing ID – just set CollapsableControl.AssociatedControlID to Panel.ClientID… but – when putting <% %> in the panel, it won’t get rendered??!!

  • 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-12T22:03:16+00:00Added an answer on May 12, 2026 at 10:03 pm

    oh, how comes – i’ve solved this problem:

    public sealed class CollapsableArea : Control
    {
        private const string ViewStateKeyCollapsableContentClientID = "collapsableContentClientID";
    
        private string CollapsableContentClientID
        {
            get
            {
                var obj = this.ViewState[ViewStateKeyCollapsableContentClientID];
                if (obj == null)
                {
                    var collapsableContentClientID = Guid.NewGuid().ToString();
                    this.ViewState[ViewStateKeyCollapsableContentClientID] = collapsableContentClientID;
                    return collapsableContentClientID;
                }
                return (string)obj;
            }
        }
    
        /// <summary>
        /// Gets or sets the header text.
        /// </summary>
        /// <value>The header text.</value>
        public string HeaderText
        {
            get
            {
                this.EnsureChildControls();
                return this._collapseControl.Text;
            }
            set
            {
                this.EnsureChildControls();
                this._collapseControl.Text = value;
            }
        }
    
        public override ControlCollection Controls
        {
            get
            {
                // redirect controls
                return this._collapsableContent.Controls;
            }
        }
    
        #region child controls
    
        private readonly Panel _collapsableContent = new Panel();
        private readonly CollapsableControl _collapseControl = new CollapsableControl();
    
        #endregion
    
        public override Control FindControl(string id)
        {
            // need to redirect
            if (string.Equals(id, this._collapsableContent.ID))
            {
                return this._collapsableContent;
            }
            return this._collapsableContent.FindControl(id);
        }
    
        protected override void CreateChildControls()
        {
            base.Controls.Clear();
    
            var collapsableContentClientID = this.CollapsableContentClientID;
            this._collapsableContent.ID = collapsableContentClientID;
            this._collapseControl.AssociatedControlID = collapsableContentClientID;
            base.Controls.Add(this._collapseControl);
            base.Controls.Add(this._collapsableContent);
        }
    
        protected override void RenderChildren(HtmlTextWriter writer)
        {
            this._collapseControl.RenderControl(writer);
            // hack for code blocks
            if (!this.Controls.IsReadOnly)
            {
                this._collapsableContent.RenderControl(writer);
            }
            else
            {
                this._collapsableContent.RenderBeginTag(writer);
                base.RenderChildren(writer);
                this._collapsableContent.RenderEndTag(writer);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a class that looks like this: public class MyClass : IMyClass
Currently I'm trying to write my first Python library and I've encountered the following
Currently, I have something like: public partial class Form1 : Form { delegate void
Currently I am adding object by creating it like: type TRecord = class private
Currently have the following expression: @[TMS_Dest] + \\ + @[TMS_Rename] + (DT_WSTR,4)DatePart(yyyy, GetDate()) +
Currently, most of the popular websites, like google, yahoo detect if the user connection
Currently I have the following Mapping in my Controller: @RequestMapping( value = /add.html, method
Currently I have a web service, which loads up any plugins located within its
I would like to run a str_replace or preg_replace which looks for certain words
Currently, Django 1.2.3 User model unicode is def __unicode__(self): return self.username and I'd like

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.