Dynamic Dock problems

4 posts, 0 answers
  1. shimon
    shimon avatar
    37 posts
    Member since:
    Apr 2007

    Posted 13 Jul 2007 Link to this post

    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

  2. Petya
    Admin
    Petya avatar
    869 posts

    Posted 16 Jul 2007 Link to this post

    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
  3. shimon
    shimon avatar
    37 posts
    Member since:
    Apr 2007

    Posted 16 Jul 2007 Link to this post

    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
  4. Petya
    Admin
    Petya avatar
    869 posts

    Posted 16 Jul 2007 Link to this post

    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
Back to Top