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"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <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"; currentLoadingPanel.show(currentUpdatedControl); } function ResponseEnd() { //hide the loading panel and clean up the global variables if (currentLoadingPanel != null) currentLoadingPanel.hide(currentUpdatedControl); currentUpdatedControl = null; currentLoadingPanel = null; } </script> </telerik:RadCodeBlock> </head> <body> <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"> <tr> <td> <telerik:RadDockZone ID="RDZoneLeft" runat="server" Width="300" MinHeight="300" ></telerik:RadDockZone> </td> <td> <telerik:RadDockZone ID="RDZoneRight" runat="server" Width="300" MinHeight="300" ></telerik:RadDockZone> </td> </tr> </table> </telerik:RadDockLayout> </asp:Panel> </div> <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> </form> </body> </html> 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 'Get saved state string from the database - set it to dockState variable for example Dim dockStatesFromDB As String = "" _conn.Open() Dim command As New SqlCommand("select state from IFM_User_Page_Layout where UserID=999999", _conn) dockStatesFromDB = command.ExecuteScalar().ToString() _conn.Close() 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 _currentDockStates.Add(DockState.Deserialize(stringState)) End If Next 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)) CreateSaveStateTrigger(dock) ' LoadWidget(dock) RDLayout.Controls.Add(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 Next 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 serializedList.Append(stateList(i).ToString()) serializedList.Append("|") System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) End While Dim dockState As String = serializedList.ToString() If dockState.Trim() <> [String].Empty Then _conn.Open() Dim command As New SqlCommand([String].Format("update States set State='{0}' where id='" + _userID.ToString() + "'", dockState), _conn) command.ExecuteNonQuery() _conn.Close() 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.ApplyState(state) 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" setting1.UpdatedControls.Add(updatedControl) Dim setting2 As New AjaxSetting(dock.ID) setting2.EventName = "Command" setting2.UpdatedControls.Add(updatedControl) RAManager.AjaxSettings.Add(setting1) RAManager.AjaxSettings.Add(setting2) End Sub End ClassAnd 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