Loading Dockstates from DB

4 posts, 0 answers
  1. Geoff
    Geoff avatar
    28 posts
    Member since:
    Jul 2010

    Posted 31 Jul 2010 Link to this post

    Hi there

    I have been experimenting with loading and saving dock states to a DB but have an issue.

    When I run the code the docks are not added to the page - rather they are but the source code has a 'style display:none' so I presume this is hiding the docks?? Its all I can think off as I cant see any other issues.

    Can somebody have a look below and see what I am doing wrong........

    This is the ASPX.................

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test Docks.aspx.vb" Inherits="IFM_Code_Testing.Test_Docks" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                var currentLoadingPanel = null;
                var currentUpdatedControl = null;
                function RequestStart(sender, args) {
                    currentLoadingPanel = $find("LoadingPanel1");
                    currentUpdatedControl = "TableLayout";
                function ResponseEnd() {
                    //hide the loading panel and clean up the global variables
                    if (currentLoadingPanel != null)
                    currentUpdatedControl = null;
                    currentLoadingPanel = null;
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div >
            <asp:Panel ID="Panel1" runat="server">
                <telerik:RadDockLayout ID="RDLayout" Runat="server" OnSaveDockLayout="RDLayout_SaveDockLayout" OnLoadDockLayout="RDLayout_LoadDockLayout" EnableEmbeddedSkins="false">
                    <table id="TableLayout">
                                <telerik:RadDockZone ID="RDZoneLeft" runat="server" Width="300" MinHeight="300" ></telerik:RadDockZone>
                                <telerik:RadDockZone ID="RDZoneRight" runat="server" Width="300" MinHeight="300"  ></telerik:RadDockZone>
        <telerik:RadAjaxManager ID="RAManager" runat="server" ClientEvents-OnRequestStart="RequestStart" ClientEvents-OnResponseEnd="ResponseEnd"></telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" MinDisplayTime="500" Skin="Default"></telerik:RadAjaxLoadingPanel>

    And this is the ASPX.VB...
    Imports System
    Imports System.Collections.Generic
    Imports System.Web
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports Telerik.Web.UI
    Imports System.Text
    Imports System.Data.SqlClient
    Imports System.Collections
    Imports System.Configuration
    Public Class Test_Docks
        Inherits System.Web.UI.Page
        Private _conn As New SqlConnection(ConfigurationManager.ConnectionStrings("dbconnectionsstring").ConnectionString)
        Private _userID As Integer = 999999
        Private ReadOnly Property CurrentDockStates() As List(Of DockState)
                'Get saved state string from the database - set it to dockState variable for example 
                Dim dockStatesFromDB As String = ""
                Dim command As New SqlCommand("select state from IFM_User_Page_Layout where UserID=999999", _conn)
                dockStatesFromDB = command.ExecuteScalar().ToString()
                Dim _currentDockStates As New List(Of DockState)()
                Dim stringStates As String() = dockStatesFromDB.Split("|"c)
                For Each stringState As String In stringStates
                    If stringState.Trim() <> String.Empty Then
                    End If
                Return _currentDockStates
            End Get
        End Property
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        End Sub
        Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
            'Recreate the docks in order to ensure their proper operation
            Dim i As Integer = 0
            While i < CurrentDockStates.Count
                If CurrentDockStates(i).Closed = False Then
                    Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i))
                       ' LoadWidget(dock)
                End If
                System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            End While
        End Sub
        Protected Sub RDLayout_LoadDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)
            For Each state As DockState In CurrentDockStates
                e.Positions(state.UniqueName) = state.DockZoneID
                e.Indices(state.UniqueName) = state.Index
        End Sub
        Protected Sub RDLayout_SaveDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)
            Dim stateList As List(Of DockState) = RDLayout.GetRegisteredDocksState()
            Dim serializedList As New StringBuilder()
            Dim i As Integer = 0
            While i < stateList.Count
                System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            End While
            Dim dockState As String = serializedList.ToString()
            If dockState.Trim() <> [String].Empty Then
                Dim command As New SqlCommand([String].Format("update States set State='{0}' where id='" + _userID.ToString() + "'", dockState), _conn)
            End If
        End Sub
        Private Function CreateRadDockFromState(ByVal state As DockState) As RadDock
            Dim dock As New RadDock()
            dock.DockMode = DockMode.Docked
            dock.ID = String.Format("RadDock{0}", state.UniqueName)
            dock.Commands.Add(New DockCloseCommand())
            dock.Commands.Add(New DockExpandCollapseCommand())
            Return dock
        End Function
        Private Sub CreateSaveStateTrigger(ByVal dock As RadDock)
             dock.AutoPostBack = True
            dock.CommandsAutoPostBack = True
            Dim updatedControl As New AjaxUpdatedControl()
            updatedControl.ControlID = "Panel1"
            Dim setting1 As New AjaxSetting(dock.ID)
            setting1.EventName = "DockPositionChanged"
            Dim setting2 As New AjaxSetting(dock.ID)
            setting2.EventName = "Command"
        End Sub
    End Class

    And this is the state data from thr db (copied from an example on this site)...

    {"UniqueName":"10bcf490-d081-4536-b542-df1564a8cade","DockZoneID":"RDZoneLeft","Width":"300px","Height":"","ExpandedHeight":"203","Top":"0px","Left":"0px","Resizable":"False","Closed":"False","Collapsed":"False","Pinned":"False","Title":"Dock","Text":"Added at 12/3/2009 3:40:54 PM","Tag":"~/Controls/ExchangeRates.ascx","Index":"0"}|{"UniqueName":"35ca0eed-774e-48f6-91ab-91dad4253153","DockZoneID":"RDZoneRight","Width":"300px","Height":"","ExpandedHeight":"138","Top":"0px","Left":"0px","Resizable":"False","Closed":"False","Collapsed":"False","Pinned":"False","Title":"Dock","Text":"Added at 12/3/2009 3:41:05 PM","Tag":"~/Controls/Horoscopes.ascx","Index":"0"}|

    I cant seem to find any issues apart from the style one mentioned previously.

    Any help greatly appreciated

  2. Geoff
    Geoff avatar
    28 posts
    Member since:
    Jul 2010

    Posted 31 Jul 2010 Link to this post

    And this is the source code generated.....

    <table id="TableLayout">
                                <div id="RDZoneLeft" class="RadDockZone RadDockZone_Hay rdVertical" style="width:300px;min-width:10px;min-height:300px;">
            <!-- 2010.2.713.40 --><div class="RadDock RadDock_Default rdPlaceHolder" id="RDZoneLeft_D" style="display:none;">
                <!-- -->
            </div><input id="RDZoneLeft_ClientState" name="RDZoneLeft_ClientState" type="hidden" />
                                <div id="RDZoneRight" class="RadDockZone RadDockZone_Hay rdVertical" style="width:300px;min-width:10px;min-height:300px;">
            <div class="RadDock RadDock_Default rdPlaceHolder" id="RDZoneRight_D" style="display:none;">
                <!-- -->
            </div><input id="RDZoneRight_ClientState" name="RDZoneRight_ClientState" type="hidden" />
  3. Geoff
    Geoff avatar
    28 posts
    Member since:
    Jul 2010

    Posted 31 Jul 2010 Link to this post

    Ok I have managed to get this working - used an example and went from there.

    I set up a simple page and can now load/save from DB.


    When I try and intergrate the working code into a Master Page the docks do not get loaded..

    I have a master page setup in which there are 3 ContentPlaceHolders. Then on a child page, based on the Master, I have added the code I have had working.

    But when I load the page no docks????

    Is there something else I need to do to get it to work with MasterPages?

    The code is basically what I have alreayd showed previously.

    Thanks in advance

  4. Geoff
    Geoff avatar
    28 posts
    Member since:
    Jul 2010

    Posted 01 Aug 2010 Link to this post

    Hi there - please ignore this thread - all sorted now.

    Made of couple of silly errors but got it sorted and everything working as it should.
Back to Top