473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Accordion not maintaining state on postback

1
I'm creating a user control to prompt for crystal reports parameters. The individual controls work fine, and the over all control works fine too.

However, I'm not really that experienced in the use of dynamic controls and am having some issues with getting the accordion to work properly.

What happens when one of my user controls fires a postback is that the accordion gets set back to the first pane. I suspect that this is happening because I'm repopulating the control. I have thought that maybe I could set an "ID" for each control as it is added, and then get every control to set its "ID" into the viewstate somewhere so that I could set the correct accordion pane to display, but this seems overly complicated.

Question:Can anyone here suggest a better way of doing this?

another question: I'm also interested to know if I actually have to retrieve the controls with the LoadControl() method each time. This seems a little cumbersom?



Here is the complete code for my "containing" control....


Expand|Select|Wrap|Line Numbers
  1. public partial class CrystalReportsParameterControls_ParameterPrompt : System.Web.UI.UserControl
  2. {
  3.  
  4.     ParameterFieldDefinitions m_ParameterFieldDefinitions;
  5.     List m_PageControls;
  6.     List m_AccordionPanes;
  7.  
  8.     #region Properties
  9.     public ParameterFieldDefinitions ParameterFieldDefinitions
  10.     {
  11.         get
  12.         { return m_ParameterFieldDefinitions; }
  13.         set
  14.         { m_ParameterFieldDefinitions = value; }
  15.     }
  16.  
  17.     public List PageControls
  18.     {
  19.         get
  20.         {
  21.             if (m_PageControls == null)
  22.             {
  23.                 m_PageControls = new List();
  24.             }
  25.             return m_PageControls;
  26.         }
  27.         set
  28.         {
  29.             if (m_PageControls == null)
  30.             {
  31.                 m_PageControls = new List();
  32.             }
  33.             m_PageControls = value;
  34.         }
  35.     }
  36.  
  37.     public List AccordionPanes
  38.     {
  39.         get
  40.         {
  41.             if (m_AccordionPanes == null)
  42.             {
  43.                 m_AccordionPanes = new List();
  44.             }
  45.             return m_AccordionPanes;
  46.         }
  47.         set
  48.         {
  49.             if (m_AccordionPanes == null)
  50.             {
  51.                 m_AccordionPanes = new List();
  52.             }
  53.             m_AccordionPanes = value;
  54.         }
  55.     }
  56.     #endregion
  57.  
  58.  
  59.     protected void LoadUI()
  60.     {
  61.         Accordion l_Accordion = LoadAccordionControl();
  62.  
  63.         // Loop thru List of controls and add each to teh pane
  64.         foreach (AccordionPane ap in AccordionPanes)
  65.         {
  66.             l_Accordion.Panes.Add(ap);
  67.             //panelParameterPrompt.Controls.Add(uc);
  68.         }
  69.  
  70.         panelParameterPrompt.Controls.Add(l_Accordion);
  71.  
  72.      }
  73.  
  74.     protected Accordion LoadAccordionControl()
  75.     {
  76.         Accordion l_Accordion = new Accordion();
  77.  
  78.         l_Accordion.ID = "m_accParameterControls";
  79.         l_Accordion.SuppressHeaderPostbacks = true;
  80.         l_Accordion.HeaderCssClass="accordionHeader";
  81.         l_Accordion.ContentCssClass="accordionContent"; 
  82.         l_Accordion.FadeTransitions=true;
  83.         l_Accordion.FramesPerSecond=40; 
  84.         l_Accordion.TransitionDuration=250;
  85.         l_Accordion.Width = 500;
  86.         l_Accordion.AutoSize = AutoSize.None;
  87.         l_Accordion.EnableViewState=true;
  88.  
  89.         return l_Accordion;
  90.     }
  91.  
  92.     protected void Page_Init(object sender, EventArgs e)
  93.     {
  94.  
  95.             BaseCrystalReportParameterControl pc;
  96.             AccordionPane ap;
  97.             Label lbl;
  98.  
  99.             foreach (ParameterFieldDefinition pfd in ParameterFieldDefinitions)
  100.             {
  101.  
  102.                 if (pfd.ParameterFieldUsage == ParameterFieldUsage.InUse)
  103.                 {
  104.                     pc = new BaseCrystalReportParameterControl();
  105.                     ap = new AccordionPane();
  106.                     lbl = new Label();
  107.  
  108.                     if (pfd.ReportName.Length == 0) // Has no name if belongs to main report, else Sub report.
  109.                     {
  110.  
  111.                         if (pfd.ParameterValueKind == ParameterValueKind.DateParameter)
  112.                         {
  113.                             pc = LoadDiscreteDate();
  114.                             pc.ParameterFieldDefinition = pfd;
  115.                         }
  116.  
  117.                         if (pfd.ParameterValueKind == ParameterValueKind.StringParameter)
  118.                         {
  119.                             pc = LoadDiscreteValueStringWithDefaults();
  120.                             pc.ParameterFieldDefinition = pfd;
  121.                         }
  122.  
  123.                         ap.ContentContainer.Controls.Add(pc);
  124.                         lbl.Text = pc.ParameterFieldDefinition.PromptText;
  125.                         ap.HeaderContainer.Controls.Add(lbl);
  126.                         //PageControls.Add(pc);
  127.                         AccordionPanes.Add(ap);
  128.  
  129.                     }
  130.                 }
  131.             }
  132.  
  133.             LoadUI();
  134.     }
  135.  
  136.  
  137.     private CrystalReportsParameterControls_DiscreteValueStringWithDefaults LoadDiscreteValueStringWithDefaults()
  138.     {
  139.         CrystalReportsParameterControls_DiscreteValueStringWithDefaults myControl = new CrystalReportsParameterControls_DiscreteValueStringWithDefaults();
  140.  
  141.         myControl = (CrystalReportsParameterControls_DiscreteValueStringWithDefaults)LoadControl("~/CrystalReportsParameterControls/DiscreteValueStringWithDefaults.ascx");
  142.  
  143.         return myControl;
  144.     }
  145.  
  146.     private CrystalReportsParameterControls_DiscreteValueDate LoadDiscreteDate()
  147.     {
  148.         CrystalReportsParameterControls_DiscreteValueDate myControl = new CrystalReportsParameterControls_DiscreteValueDate();
  149.  
  150.         myControl = (CrystalReportsParameterControls_DiscreteValueDate)LoadControl("~/CrystalReportsParameterControls/DiscreteValueDate.ascx");
  151.  
  152.         return myControl;
  153.     }
  154.  
  155.     public ParameterFieldDefinitions GetParameterSettings
  156.     {
  157.         get
  158.         {
  159.             return m_ParameterFieldDefinitions;
  160.         }
  161.     }
  162.  
  163.     public void ApplyParameterValues()
  164.     {
  165.         foreach (BaseCrystalReportParameterControl uc in PageControls)
  166.         {
  167.             uc.ApplyParameterValues();
  168.         }
  169.     }
  170. }
Mar 4 '08 #1
0 1829

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pete Moss | last post by:
During a postback event, I am having trouble retrieving the state of a CheckBox Control that I am dynamically adding to a DataGrid Control using ASP.NET 1.1. I have no trouble adding the...
1
by: Deepson Thomas | last post by:
Hi, Currently iam facing a strange problem.. One dropdown in my page is keeping itz state after postback. Whichever the item i selected is not the selected item after postback. it goes back to the...
5
by: Deepson Thomas | last post by:
Hi, Currently iam facing a strange problem.. One dropdown in my page is not keeping itz state after postback. Whichever the item i select irrespective of that after the post-back the default...
1
by: clintonG | last post by:
I'm having a problem maintaining state with a Panel control in a MasterPage and I need help thinking through this process. The basic structure of the HTML in the Master looks like this... ...
1
by: noneya22 | last post by:
I have an accordion control with a dynamically generated asp.net checkbox server-side control in each accordion pane. On postback I loop through all of the controls on the page, and I never find...
4
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I am just stating to use ajax, and have a perfect place to use the accordion control. I have it working fine, but need to have a normal asp button in one of the panes that fires an onclick event...
1
by: luispunchy | last post by:
I have an accordion style dropdown list/sublist menu (functions similar to the "today on WebMD video" widget found on http://www.webmd.com/) - it will allow users to click on a headline (from the...
1
by: John Graham | last post by:
I have a form where I separate several of the sections with the use of an accordion. Because of the requirements I have, I need the form to be saved every time the user clicks on a different pane...
3
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.