Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Docking > Dock Save State Position Not size
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Dock Save State Position Not size

Feed from this thread
  • Ryan Grossman Intermediate avatar

    Posted on Sep 4, 2009 (permalink)

    I'm using the standard RadDockingManager1.SaveState() and RadDockingManager1.LoadState(CStr(state)) to save my webpage layouts for each user.

    The only issue I have is if a user saves the state, it also saves the size of each dock. This creates scrollbars when they adjust the size of the window. Is there anyway to just save position, but not the actual dock size?

  • Obi-Wan Kenobi Master avatar

    Posted on Sep 7, 2009 (permalink)

    There is not such a built-in functionality. You should implement your own mechanism - iterate through all RadDocks and get the desired properties.

  • Ryan Grossman Intermediate avatar

    Posted on Jul 8, 2010 (permalink)

    Can you provide any examples as to how iterating through Raddock classic can be done? All I want to save is dock position and if minimized or not. I dont want to save dock size.

    Is there a way I can use the current save state but then manually clear the dock height and widths? That would accomplish what I want as well.

  • Pero Pero admin's avatar

    Posted on Jul 13, 2010 (permalink)

    Hi Ryan,

    The following loop will go through all dockable objects currently present on the page.

    foreach (RadDockableObject dockableObject in RadDockingManager1.DockableObjects)
    {
     
    }

    You could manually clear the Width and Height of every dock, before the state is saved.

    Regards,
    Pero
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  • Ryan Grossman Intermediate avatar

    Posted on Jul 14, 2010 (permalink)

    Can you alter my code below to clear the height and width of the dock objects. I dont see where I would put the for each logic in the savestate function. I execute the save state from a dock command and save the info to an SQL database.

    Private Sub rdoDock1_Command(sender As Object, e As EventArgs)
             Dim dockableObject As RadDockableObject = CType(sender, RadDockableObject)
             Dim commandEventArgs As RadDockableObjectCommandEventArgs = CType(e, RadDockableObjectCommandEventArgs)
               
             Dim CommandClicked As String = String.Format("{0}", commandEventArgs.Command.Name, dockableObject.ID)
               
             If CommandClicked = "rdocSaveView" Then
                Dim myCommand As SqlCommand
                Dim insertCmd As String
                insertCmd = "update WebUsersProfiles SET SavedStateView=@SavedState WHERE UserID='" & Session("UserID") & "';"
                myCommand = New SqlCommand(insertCmd, myConnection)
                myCommand.Parameters.Add(New SqlParameter("@SavedState", SqlDbType.VarChar, 5000)).Value = RadDockingManager1.SaveState() 
                myCommand.Connection.Open()
                myCommand.ExecuteNonQuery()
                myCommand.Connection.Close()
                Response.Redirect(Request.RawUrl)
             Else If CommandClicked = "rdocResetView" Then
                Dim myCommand As SqlCommand
                Dim insertCmd As String
                insertCmd = "update WebUsersProfiles SET SavedStateView='' WHERE UserID='" & Session("UserID") & "';"
                myCommand = New SqlCommand(insertCmd, myConnection)
                myCommand.Connection.Open()
                myCommand.ExecuteNonQuery()
                myCommand.Connection.Close()
                Me.Application("RadDockState") = Nothing
                Response.Redirect(Request.RawUrl)
             End If
    End Sub

  • Pero Pero admin's avatar

    Posted on Jul 15, 2010 (permalink)

    Hello Ryan,

    I believe the right place to put the code is in the  If CommandClicked = "rdocSaveView" Then block, before the code that saves the state into the DB. For example the following code will set Unit.Empty to the Width and Height of all dockable objects present on the page:

    For Each dockableObject As RadDockableObject In RadDockingManager1.DockableObjects
        dockableObject.Width = Unit.Empty
        dockableObject.Height = Unit.Empty
    Next


    Best wishes,
    Pero
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  • Ryan Grossman Intermediate avatar

    Posted on Jul 23, 2010 (permalink)

    Why do I get the following: BC30616: Variable 'dockableObject' hides a variable in an enclosing block.

    Line 351: Dim CommandClicked As String = String.Format("{0}", commandEventArgs.Command.Name, dockableObject.ID)
    Line 352:
    Line 353: For Each dockableObject As RadDockableObject In RadDockingManager1.DockableObjects
    Line 354: dockableObject.Width = Unit.Empty
    Line 355: dockableObject.Height = Unit.Empty

    My Code:
    Dim dockableObject As RadDockableObject = CType(sender, RadDockableObject)
    Dim commandEventArgs As RadDockableObjectCommandEventArgs = CType(e, RadDockableObjectCommandEventArgs)
      
    Dim CommandClicked As String = String.Format("{0}", commandEventArgs.Command.Name, dockableObject.ID)
      
    If CommandClicked = "rdocSaveView" Then
       For Each dockableObject As RadDockableObject In RadDockingManager1.DockableObjects
           dockableObject.Width = Unit.Empty
           dockableObject.Height = Unit.Empty
       Next
       Dim myCommand As SqlCommand
       Dim insertCmd As String
       If Request.QueryString("View") = "Contact" Then
           insertCmd = "update WebUsersProfiles SET SavedStateContactView=@SavedState WHERE UserID='" & Session("UserID") & "';"
       Else If Request.QueryString("View") = "Company" Then
           insertCmd = "update WebUsersProfiles SET SavedStateCompanyView=@SavedState WHERE UserID='" & Session("UserID") & "';"
       Else If Request.QueryString("View") = "Property" Then
           insertCmd = "update WebUsersProfiles SET SavedStatePropertyView=@SavedState WHERE UserID='" & Session("UserID") & "';"
       Else If Request.QueryString("View") = "Trans" Then
           insertCmd = "update WebUsersProfiles SET SavedStateTransView=@SavedState WHERE UserID='" & Session("UserID") & "';"
       End If
       myCommand = New SqlCommand(insertCmd, myConnection)
       myCommand.Parameters.Add(New SqlParameter("@SavedState", SqlDbType.VarChar, 5000)).Value = RadDockingManager1.SaveState() 
       myCommand.Connection.Open()
       myCommand.ExecuteNonQuery()
       myCommand.Connection.Close()
       Response.Redirect(Request.RawUrl)
    End If

  • Ryan Grossman Intermediate avatar

    Posted on Jul 23, 2010 (permalink)

    I dont if this is acceptable or not, but I just clear the height on page load if the state is saved. This seems to be working. I noticed if I clear the width, all the docks are to small. I would like them to be 100% of the docking zone.

    The issue is I save the state on a pc with 1600x1200, then access the site on a 1024x768. I want to clear the width and height and then set the width to 100%. Can the code below be altered to set width to empty and then 100%?

        For Each dockableObject As RadDockableObject In RadDockingManager1.DockableObjects
         dockableObject.Width = Unit.Empty
         dockableObject.Height = Unit.Empty
        Next

  • Pero Pero admin's avatar

    Posted on Jul 27, 2010 (permalink)

    Hello Ryan,

    The error BC30616: Variable 'dockableObject' hides a variable in an enclosing block. comes from the fact that you have defined two variables with the same name:
    Dim dockableObject As RadDockableObject = CType(sender, RadDockableObject)
    Dim commandEventArgs As RadDockableObjectCommandEventArgs = CType(e, RadDockableObjectCommandEventArgs)
       
    Dim CommandClicked As String = String.Format("{0}", commandEventArgs.Command.Name, dockableObject.ID)
       
    If CommandClicked = "rdocSaveView" Then
       For Each dockableObject As RadDockableObject In RadDockingManager1.DockableObjects
           dockableObject.Width = Unit.Empty

    Please change the name to one of the variables.

    Would it be a problem if you directly set the Width to 100%? The following code sets 100% to the dock's Width:
    dockableObject.Width = New Unit(100, UnitType.Percentage)


    Greetings,
    Pero
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  • Ryan Grossman Intermediate avatar

    Posted on Jul 27, 2010 (permalink)

    Excellent, thanks...

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Docking > Dock Save State Position Not size