473,756 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accordion not maintaining state on postback

1 New Member
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 1868

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

Similar topics

2
2457
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 TemplateColumn dynamically. I persist a DataSet in my Session object and I bind the CheckBox to the DataSet. So far so good. The CheckBoxes show up and the user interacts with them (checks a few, unchecks a few). The problem is that during a postback...
1
1447
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 first item again. This happens even if i submitted the page by making the AutoPostback of the dropdown true or by clicking on the submit button. Even itz not going to the DropDownList1_SelectedIndexChanged method. A checking is already there...
5
2099
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 selected item is the first one. This happens even if i submitted the page by making the AutoPostback of the dropdown true or by clicking on the submit button. Even it’s not going to the DropDownList1_SelectedIndexChanged method. A checking is...
1
2152
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... <asp:PanelActivatorLinkButton ... /> .... .... <asp:Panel Visible="" ...> <asp:LoadContentLinkButton ... /> <asp:ContentPlaceHolder ... />
1
3308
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 one that is of type checkbox. If I get rid of the accordion control, the same code works fine. I tried looping through the request object in search of client-side checkboxes, but this failed too. Are there any known issues with the accordion...
4
6277
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 as normal. The button works fine outside of the pane, but once I put it in the pane it no longer fires the event. How can I get a button in the accordion to run a function on the server on the onclick event? Thanks.
1
2672
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 main list) to open up the full listing (sublist) below that headline. My JavaScript is almost but not quite working as needed. It also serves up an error that an object "has no properties". The particular error message and line of code it refers to:...
1
8746
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 of the accordion. I am not able to find an event I can use to do this. Any suggestions would be appreciated.
3
5275
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 add the pane the remove event does not get handled, though thereafter it is handled without problems. ==================================================
0
9462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8723
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.