Hi,
I have a situation where I need to add usercontrols dynamically & in those usercontrols add RadDocks dynamically which itself contains usercontrol.
Following is the code I am using to add RadDocks in parent usercontrol
in .ascx
in .ascx.cs
Now the problem is when I change the positions of RadDock Panels changes to state doesn't persist.
In
I am not using LoadDockLayout event as indices of RadDocks are same as they are added.
I must be making some silly mistake.
Please help me asap.
Regards,
Suraj Patil
I have a situation where I need to add usercontrols dynamically & in those usercontrols add RadDocks dynamically which itself contains usercontrol.
Following is the code I am using to add RadDocks in parent usercontrol
in .ascx
<
telerik:RadDockLayout
runat
=
"server"
ID
=
"QuestionsDockLayout"
>
<
telerik:RadDockZone
ID
=
"RadDockZone1"
runat
=
"server"
/>
</
telerik:RadDockLayout
>
in .ascx.cs
private
bool
_shouldSavesState =
false
;
protected
void
Page_Init(
object
sender, EventArgs e)
{
QuestionsDockLayout.SaveDockLayout += QuestionsDockLayout_SaveDockLayout;
LoadQuestions();
}
private
void
LoadQuestions()
{
foreach
(var zone
in
QuestionsDockLayout.RegisteredZones)
{
zone.Docks.Clear();
zone.Controls.Clear();
}
if
(!
string
.IsNullOrEmpty(XmlNode_Page))
{
XmlDocument xmldoc_page =
new
XmlDocument();
xmldoc_page.Load(
new
StringReader(XmlNode_Page));
XmlNodeList nodePages = xmldoc_page.SelectNodes(
"//Question"
);
if
(nodePages !=
null
&& nodePages.Count > 0)
{
for
(
int
i = 0; i < nodePages.Count; i++)
{
RadDock radDock =
new
RadDock();
radDock.ID =
"dockPanel_"
+
this
.ID +
"_Q"
+ i;
radDock.AutoPostBack =
true
;
radDock.Resizable =
false
;
radDock.DockMode = DockMode.Docked;
radDock.DockHandle = DockHandle.None;
radDock.OnClientInitialize =
"SetHandleDock"
;
QuestionsDockLayout.RegisteredZones[0].Controls.Add(radDock);
XmlNode XnodeQuestion = nodePages[i];
UC_SurveyQuestion SQ = (UC_SurveyQuestion)LoadControl(
"~/UserControls/UC_SurveyQuestion.ascx"
);
SQ.ID = XnodeQuestion.Attributes[
"id"
].Value;
SQ.XmlNode_Question = XnodeQuestion.OuterXml;
SQ.Page_ID =
this
.ID;
HtmlImage img = SQ.FindControl(
"Handle"
)
as
HtmlImage;
img.ClientIDMode = System.Web.UI.ClientIDMode.Static;
img.ID =
"Handle_"
+ radDock.ClientID;
radDock.ContentTemplate =
new
CompiledTemplateBuilder(parent =>
parent.Controls.Add(SQ)
);
radDock.DockPositionChanged += dock_DockPositionChanged;
}
}
}
private
void
dock_DockPositionChanged(
object
sender, DockPositionChangedEventArgs e)
{
//if dock position was changed set a flag for saving dock state
_shouldSavesState =
true
;
}
private
void
QuestionsDockLayout_SaveDockLayout(
object
sender, DockLayoutEventArgs e)
{
//Save dock panels state in user's profile
if
(_shouldSavesState)
{
List<DockState> lst = QuestionsDockLayout.GetRegisteredDocksState();
}
}
Now the problem is when I change the positions of RadDock Panels changes to state doesn't persist.
In
SaveDockLayout event GetRegistered
DockState method returns the same state of docks as when they are added.I am not using LoadDockLayout event as indices of RadDocks are same as they are added.
I must be making some silly mistake.
Please help me asap.
Regards,
Suraj Patil