Current filter:
                                You should refresh the page.
                                  • Description:
                                    How to properly handle the situation when some controls/WebUserControls should be added into a page hierarchy at runtime based on some certain conditions?

                                    Answer:
                                    It is recommended to use the following sequence of operations when creating a control (or loading a WebUserControl) dynamically:
                                    1)
                                    - Control: Create a new control instance via the control type constructor:
                                    - WebUserControl: Load a WebUserControl (*.acsx file) by its virtual path via the LoadControl method:
                                    2) Specify the control ID property;
                                    3) Specify the SkinID and EnableTheming properties of the control if required.
                                    4) Attach event handlers:
                                    (see the ASP.NET Page Life Cycle Overview MSDN help topic to learn more about the order of events/stages)
                                    5) Insert the control into the entire controls hierarchy;
                                    6) Specify the control's properties;
                                    7) Bind the control (for data-aware controls).
                                    Note once you have modified the entire controls hierarchy (i.e., added the control into the controls collection), it is necessary to restore this control with the same settings during the Page_Init stage.
                                    The linked E1238 - How to create controls dynamically Code Central example illustrates these solutions in action.

                                Show all comments
                                • Mark Wenner 06.10.2014

                                  Sounds good Mike.  I need to be able to place these controls at specific x,y coordinates, with specific height, width, font, etc.  Is this possible?

                                • Mike (DevExpress Support) 06.11.2014

                                  Hello,

                                  This KB Article contains main recommendations related to the subject and is available to All Users.
                                  I have extracted your Comment to a corresponding Ticket:
                                  T116540: How to dynamically create Controls with Web Components
                                  Please refer to it for further correspondence.

                                • James3 02.06.2015

                                  Hi Mike,
                                  Sorry if this is a silly question, but not sure how to add the event handlers. I can get it to load using a UserControl, and you can edit the data but none of the menu items are working.

                                • Mike (DevExpress Support) 02.06.2015

                                  Hello James,

                                  To process your recent post more efficiently, I created a separate ticket on your behalf: T205991: Dynamic UserControl - How to add Event Handlers. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

                                • Dmitri Rechetilov 1 03.06.2015

                                  I have struggled with this for a while..
                                  What's eventually worked for me is adding it into OnLoad (not Page_Init as suggested, because in Page_Init there were no values returned from another control :-[ ). IE:
                                         protected override void OnLoad(EventArgs e)
                                         {
                                             base.OnLoad(e);
                                             UpdateCustomControls();
                                         }

                                • Mike (DevExpress Support) 03.06.2015

                                  Hello Dmitri,

                                  To process your recent post more efficiently, I created a separate ticket on your behalf: T216535: How to create controls dynamically on Page Load. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

                                • Shruti Jauhari 10.04.2016

                                  I have a similar problem on Winform, where I have a Xtraform and few panels. Depending on the user selection I need to add or remove panel from form controls. Below code doesn't work.

                                  this.pnlDT.Location = new System.Drawing.Point(2, 57);
                                  this.pnlDT.Size = new System.Drawing.Size(517, 254);
                                  this.Controls.Add(pnlDT);

                                  Note: this is instance of class inheriting XtraForm

                                  Please assist. Thanks!

                                • Lex (DevExpress Support) 10.04.2016

                                  Hello Shruti,
                                  I've created a separate ticket on your behalf (T435512: How to create controls dynamically). It has been placed in our processing queue and will be answered shortly.

                                0 Solutions

                                Creation Date Importance Sort by