Hello everyone,
I have 2 rad zones with 2 docks in each one.
lets take one of these zones [ which has 2 docks ]
whenever I try to position the lower dock up in the zone it will go back down [ its not that I'm not placing it right ]
Any idea why its happening, and how to fix ?!
Best Regards,
9 Answers, 1 is accepted
Probably once you dropped a RadDock an automatic Postback or Ajax call occurs. Keep in mind that if you want to preserve the state your RadDock controls should be wrapped in a RadDockLayout. Also if you create RadDocks dynamically you should create them in PageInit.
Thanks for your reply Obi-Wan Kenobi
Actually I'm not dynamically creating them, I dragged :
1 X RadDockLayout
3 X RadDockZones
6 X RadDocks [ Divided as two in each zone ]
What I really want is to let the user able to chose which dock would be up and which one is in the middle or down.
Any hint plz ?!
Best regards,
Sorry for the late reply.
What I want is something basic like this :
http://demos.telerik.com/aspnet/Dock/Examples/SaveLoadState/DefaultCS.aspx
At that demo when you place object 1 down and object 2 up it will stay at that place.
But the one that I have, when I place object 1 [ that I placed it 1st ] on top of object 2.
Any idea why its happening ?!
Thanks a lot for your support, and repeating my apologize for the lateness.
If you drag a RadDock1 and drop it over RadDock2, RadDock1 will be docked before RadDock2. If you want to dock RadDock1 after RadDock2 you should place it between RadDock2 and the RadDockZone's end.
Thanks Obi-Wan Kenobi for the fast reply,
I'm placing it in the right place, but whats happening is the following :
2 X RadDockZone [ RadDockZone1 - RadDockZone2 ]
4 X RadDock [ RadDock1 - RadDock2 - RadDock3 - RadDock4 ]
RadDock 1 and 2 are placed in RadDockZone1
RadDock 3 and 4 are placed in RadDockZone2
I placed them in the designer statring from the docklayout, dockzones, the dock 1, 2, 3 and 4
if I moved RadDock2 from its place at RadDockZone1 to the other zone it will move successfully.
But if I moved it to the top in RadDock1 it will get back to its normal place [ @ the bottom of RadDock1 ]
Please note that I'm not dynamically generating these docks, I'm placing it from the toolbar into the designer.
Your hints & Support are highly appreciated.
Best Regards,
Please check out the following code, hope you'll figure out something out of it.
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!this.IsPostBack) |
{ |
String str1 = (String)Context.User.Identity.Name.Split('\\').GetValue(0); |
String serializedList = getSerializedString(str1); |
if (!serializedList.Equals(String.Empty)) |
{ |
String[] states = serializedList.Split('|'); |
if (ddWebParts.SelectedIndex == -1 || ddWebParts.SelectedIndex == 0) |
{ |
ddWebParts.Items.Clear(); |
if (ddWebParts.Items.Count == 0) |
{ |
RadComboBoxItem defaultItem = new RadComboBoxItem(); |
defaultItem.Text = "--- Data Blocks ---"; |
defaultItem.Value = "0"; |
ddWebParts.Items.Add(defaultItem); |
} |
for (int i = 0; i < states.Length - 1; i++) |
{ |
RadComboBoxItem item; |
DockState state = DockState.Deserialize(states[i]); |
RadDock dock = (RadDock)RadDockLayout1.FindControl(state.UniqueName); |
if (dock.Closed) |
{ |
item = new RadComboBoxItem(); |
item.Text = state.UniqueName; |
item.Value = state.UniqueName; |
ddWebParts.Items.Add(item); |
} |
} |
ddWebParts.DataBind(); |
} |
else |
{ |
for (int i = 0; i < states.Length - 1; i++) |
{ |
DockState state = DockState.Deserialize(states[i]); |
RadDock dock = (RadDock)RadDockLayout1.FindControl(state.UniqueName); |
if (dock.UniqueName.Equals(ddWebParts.SelectedItem.Text)) |
{ |
dock.Closed = false; |
ddWebParts.Items.Remove(ddWebParts.SelectedIndex); |
} |
} |
} |
} |
} |
} |
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e) |
{ |
if (!Page.IsPostBack) |
{ |
String str1 = (String)Context.User.Identity.Name.Split('\\').GetValue(0); |
String serializedList = getSerializedString(str1); |
if (serializedList != String.Empty) |
{ |
String[] states = serializedList.Split('|'); |
for (int i = 0; i < states.Length - 1; i++) |
{ |
DockState state = DockState.Deserialize(states[i]); |
RadDock dock = (RadDock)RadDockLayout1.FindControl(state.UniqueName); |
dock.ApplyState(state); |
e.Positions[state.UniqueName] = state.DockZoneID; |
e.Indices[state.UniqueName] = state.Index; |
} |
} |
} |
} |
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
protected void RadDockLayout1_SaveDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e) |
{ |
String str1 = (String)Context.User.Identity.Name.Split('\\').GetValue(0); |
List<DockState> stateList = ((RadDockLayout)sender).GetRegisteredDocksState(); |
String serializedList = ""; |
for (int i = 0; i <= stateList.Count - 1; i++) |
{ |
RadDock dock = (RadDock)RadDockLayout1.FindControl(stateList[i].UniqueName); |
DockState state = DockState.Deserialize(stateList[i].ToString()); |
dock.ApplyState(state); |
e.Positions[state.UniqueName] = state.DockZoneID; |
e.Indices[state.UniqueName] = state.Index; |
serializedList += stateList[i]; |
serializedList += "|"; |
} |
InsertPersonalization(str1, serializedList); |
if (serializedList != String.Empty) |
{ |
String[] states = serializedList.Split('|'); |
for (int i = 0; i < states.Length - 1; i++) |
{ |
DockState state = DockState.Deserialize(states[i]); |
RadDock dock = (RadDock)RadDockLayout1.FindControl(state.UniqueName); |
dock.ApplyState(state); |
e.Positions[state.UniqueName] = state.DockZoneID; |
e.Indices[state.UniqueName] = state.Index; |
} |
} |
} |
Thanks a lot for your continuous support.
Here are two useful links:
-RadDock Lifecycle
-Server-Side Events
hii i have problem when click on hyperlink or make redirect I lost position raddock I use 086321_SaveLoadState and
public static void LoadDockLayout(object sender, DockLayoutEventArgs e)
{
HttpCookie dockState = HttpContext.Current.Request.Cookies.Get("DockStatesCookies");
if (dockState != null)
{
string serializedList = dockState.Value;
if (serializedList != null)
{
string[] states = serializedList.Split('|');
for (int i = 0; i < states.Length; i++)
{
DockState state = DockState.Deserialize(states[i]);
e.Positions[state.UniqueName] = state.DockZoneID;
e.Indices[state.UniqueName] = state.Index;
}
}
}
}
public static void SaveDockLayoutFirst(RadDockLayout rdl)
{
HttpCookie dockState = HttpContext.Current.Response.Cookies.Get("DockStatesCookies");
if (dockState == null)
{
dockState = new HttpCookie("DockStatesCookies");
HttpContext.Current.Response.Cookies.Add(dockState);
}
List<DockState> stateList = rdl.GetRegisteredDocksState();
StringBuilder serializedList = new StringBuilder();
for (int i = 0; i < stateList.Count; i++)
{
serializedList.Append(stateList[i].ToString());
serializedList.Append("|");
}
dockState.Expires = DateTime.Today.AddMonths(1);
dockState.Value = serializedList.ToString();
}
please help
i make this but when I click to LinkButton with redirect lost position DOCK...:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
<%@ Register Src="ZarzadzanieKontem.ascx" TagName="Zarzadzanie" TagPrefix="uc1" %> |
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> |
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> |
<script type="text/javascript"> |
function SetHandleDock(dock, args) |
{ |
var dockImport = $find("<%= RadDock1.ClientID %>"); |
var dockStyle = document.getElementById("<%= RadDock1.ClientID %>"); |
var left = (screen.width - dockImport.get_width().replace("px","")) / 2; |
var top = (screen.height - dockImport.get_height().replace("px","")) / 2; |
dockStyle.style.left = left + "px"; |
dockStyle.style.top = top + "px"; |
} |
function Koniec() { |
var dockImport = $find("<%= RadDock1.ClientID %>"); |
var dockStyle = document.getElementById("<%= RadDock1.ClientID %>"); |
alert(dockStyle.style.left); |
alert(dockStyle.style.top); |
<% %> |
} |
</script> |
</asp:Content> |
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> |
<asp:MultiView ID="mvDefault" runat="server"> |
<asp:View ID="vZmienDane" runat="server"> |
<center> |
<uc1:Zarzadzanie ID="ZmianaDanych" runat="server" /> |
</center> |
</asp:View> |
</asp:MultiView> |
<telerik:RadDockLayout ID="RadDockLayout1" runat="server" enableviewstate="false" storelayoutinviewstate="false" OnSaveDockLayout="RadDockLayout1_SaveDockLayout" OnLoadDockLayout="RadDockLayout1_LoadDockLayout"> |
<telerik:RadDock ID="RadDock1" Height="200px" runat="server" Width="300px" > |
<ContentTemplate> |
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">LinkButton</asp:LinkButton> |
<asp:LinkButton ID="LinkButtson2" runat="server" onclick="LinkButton2_Click">LinkButton non redirect</asp:LinkButton> |
</ContentTemplate> |
</telerik:RadDock> |
</telerik:RadDockLayout> |
</asp:Content> |
using System; |
using System.Collections; |
using System.Configuration; |
using System.Data; |
using System.Linq; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.HtmlControls; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
using System.Xml.Linq; |
using WebMail.BLL; |
using WebMail.GlobalClasses; |
using DAL; |
using Telerik.Web.UI; |
using System.Text; |
using System.Collections.Generic; |
public partial class _Default : System.Web.UI.Page |
{ |
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!string.IsNullOrEmpty(Request.QueryString["user"])) |
{ |
mvDefault.SetActiveView(vZmienDane); |
ZmianaDanych.LoadData(Enums.TypDanych.Edycja); |
} |
} |
protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e) |
{ |
HttpCookie dockState = Page.Response.Cookies.Get("MyApplicationDockStates"); |
if (dockState == null) |
{ |
dockState = new HttpCookie("MyApplicationDockStates"); |
Page.Response.Cookies.Add(dockState); |
} |
List<DockState> stateList = ((RadDockLayout)sender).GetRegisteredDocksState(); |
StringBuilder serializedList = new StringBuilder(); |
for (int i = 0; i < stateList.Count; i++) |
{ |
serializedList.Append(stateList[i].ToString()); |
serializedList.Append("|"); |
} |
dockState.Expires = DateTime.Today.AddMonths(1); |
dockState.Value = serializedList.ToString(); |
} |
protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e) |
{ |
HttpCookie dockState = Page.Request.Cookies.Get("MyApplicationDockStates"); |
if (dockState != null) |
{ |
string serializedList = dockState.Value; |
if (serializedList != null) |
{ |
string[] states = serializedList.Split('|'); |
for (int i = 0; i < states.Length; i++) |
{ |
DockState state = DockState.Deserialize(states[i]); |
e.Positions[state.UniqueName] = state.DockZoneID; |
e.Indices[state.UniqueName] = state.Index; |
} |
} |
} |
} |
protected void LinkButton1_Click(object sender, EventArgs e) |
{ |
Response.Redirect("~/Default.aspx"); |
} |
protected void LinkButton2_Click(object sender, EventArgs e) |
{ |
} |
} |