This is a migrated thread and some comments may be shown as answers.

Dynamic Dock problems

3 Answers 234 Views
Dock
This is a migrated thread and some comments may be shown as answers.
shimon
Top achievements
Rank 1
shimon asked on 13 Jul 2007, 09:11 AM

Hello,

I’m creating docks dynamically and store them in a database. It’s based on your example “PortalSiteCS”.

Every dock has 4 DockCommand, every dock loads his UserControl. The user can create the same dock on the page as many times as he wish. Every dock gets an uniqe id.

I get an error “Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.”. This error don’t raises every time. Also sometimes I get an error that says that the id of two docks is the same but if I debug it I see a different id. This error raises when I move the dock from one zone to another zone (left and right).

Is it an error in Prometheus docks?

We can’t lunch our site for bate testing with this bug.

Thanks,

Shimon Shed

3 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 16 Jul 2007, 07:38 AM
Hello shimon,

The error you describe is not a bug in RadDock Prometheus. This error appears when you dynamically create controls not complying correctly with the page life cycle.  Please, read the following instructions that explain a bit how to use the control so that you do not get such errors and make sure your code complies with them:

                    Page.PreInit
                    Controls.Init
                    Page.Init
                    Page.TrackViewState
                    Controls.TrackViewState
                    Page.InitComplete
                        RadDockLayout.LoadDockLayout
                    if(IsPostBack)
                    {
                                  Page.LoadViewState;<-----------------1
                                  Controls.LoadViewState
                    }
                    Controls.LoadPostData
                        RadDock.DockPositionChanged
                    Page.PreLoad<---------------------------- 3
                    Page.Load
                    Controls.Load
                    Controls.DataChangedEvents (such as TextBox.TextChanged)<------------ 4
                    Controls.PostBackEvents (such as Button.Click)
                        RadDock.OnCommand
                    Page.LoadComplete
                    Page.PreRender
                    Controls.PreRender
                    Page.PreRenderComplete
                    Controls.SaveViewState <----------------------- 2
                    Page.SaveViewState
                    Page.SaveStateComplete
                        RadDockLayout.SaveDockLayout
                    Render
               
  •     In point 1) on postback the control tree and the control IDs should be
    exactly the same as it was in point 2) before the postback
    - otherwise you will get ViewState exceptions. This is the cause of the error you get.
  •     You should create the controls before point 4) if you want to use their
    PostData or PostEvents.
  •     You should create the RadDock controls before
    RadDock.DockPositionChanged, in order to ensure their proper operation.
    Usually, the best place is Page.Init.
  •     You could save the dock state anywhere after Page.Load. You could use a
    Button.Click event, but in most of the scenarios we recommend the
    RadDockLayout.SaveDockLayout event because it is raised automatically
    in the proper moment.

Greetings,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
shimon
Top achievements
Rank 1
answered on 16 Jul 2007, 02:07 PM
Hello Pethya,
As we do not use the viewstate - we fixed the problem by setting our usercontrol.enableviewstate to FALSE Thanks anyway

Now we encountered a different problem: when moving a dock a little bit and leaving the mouse button - more than 2 or 3 times - we receive an eror message:
Microsoft JScript runtime error: Sys.InvalidOperationException: Two components with the same id 'Controls_uc_DesignXone_170' can't be added to the application.

Maybe you know where this comes from? And strange enough - the ID this message refers to is indeed one of our dock's ID. But all of our ID are unique !!

Thanks in advance
Shimon
0
Petya
Telerik team
answered on 16 Jul 2007, 02:48 PM
Hi shimon,

Your problem resembles a lot the scenario described here. Please, read this thread and if you have a different scenario or even after applying the thread's suggestions you continue to experience the same problem, then I would ask you to open a support ticket and send us a simple page that reproduces the issue and we will work on it.

Kind regards,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Dock
Asked by
shimon
Top achievements
Rank 1
Answers by
Petya
Telerik team
shimon
Top achievements
Rank 1
Share this question
or