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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:05:01+00:00 2026-05-15T23:05:01+00:00

I have a somewhat complex custom user control, created in C# .NET, which is

  • 0

I have a somewhat complex custom user control, created in C# .NET, which is essentially a tree structure. The control , ctlGroup, contains a list of fields (which are also custom user controls – ctlFields) and a list of child groups. The datalist containing the child groups creates new instances of the same ctlGroup control, because each of the children can have a list of fields and a list of children, and so on. Whew.

The number of children each group can have is finite, and each child group is an entry in a database, so infinite recursion is not possible. The controls are created fine, and displayed fine, until a post-back occurs. I have been able to persist all the data pertaining to each dynamically created control pretty well on post back, with one exception. The part I am having trouble with is maintaining the visibility of certain panels on the controls through postback. Each child group has a button that expands and collapses part of the body. I can collapse this portion once, but as soon as I click the button again (i.e. cause a postback), the control is persisted and it’s previous visibility setting is lost.

I seem to be struggling with coming up with a way to store this information. I tried saving the state of the visibility in the viewstate, but it seems this information does not carry over when the control is recreated.

Does anyone have any ideas for how to do this? Am I missing something?

edit: I should clarify that the ctlGroup controls that are created in the datalist are created dynamically because they are recursive calls. I don’t know any other way to call a control from itself, but if t here is a better way, I would love to hear it.

  • 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-15T23:05:02+00:00Added an answer on May 15, 2026 at 11:05 pm

    My suggestion:

    Store the ID’s of “expanded” options in a hidden field. They could recursively have links to expanded children as well. This would be your “expanded-nodes” tree structure. In JSON it would look like this (stored as a string in the hidden field):

    [{
        id: "root1", 
        children: [{id: "sub-root1", children: []}, {id: "sub-root2", children: []}]
     },
     {
        id: "root2",
        children: []
     }]
    

    Then on postback, attach a handler on the document.load event ($addHandler(document, "load", function (){ ... }) that parses your hidden field’s JSON. When the iterator visits an expanded node, it “clicks” the actual expand button (call .click() on the found element). This would re-build the “expanded” structure.

    HTH

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

Sidebar

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.