This is a migrated thread and some comments may be shown as answers.
Dynamic Dock - Telerik Example
2 Answers 46 Views
This is a migrated thread and some comments may be shown as answers.
cbospikes
Top achievements
Rank 1
cbospikes asked on 05 Jun 2009, 02:16 AM
I am using the following code straight from the demo.
If I can get this working I can modify to suit me needs from there.
When I add a dock it simply replaces the existing dock.
I'm assuming that there is some code that is not on the demo page that I need to make this work.


Partial

 

Public Class DynamicControlTest

 

 

Inherits System.Web.UI.Page

 

 

Private Property CurrentDockStates() As List(Of DockState)

 

 

Get

 

 

Dim _currentDockStates As List(Of DockState) = DirectCast(Session("CurrentDockStatesDynamicDocks"), List(Of DockState))

 

 

If [Object].Equals(_currentDockStates, Nothing) Then

 

_currentDockStates =

New List(Of DockState)()

 

Session(

"CurrentDockStatesDynamicDocks") = _currentDockStates

 

 

End If

 

 

Return _currentDockStates

 

 

End Get

 

 

Set(ByVal value As List(Of DockState))

 

Session(

"CurrentDockStatesDynamicDocks") = value

 

 

End Set

 

 

End Property

 

 


Dim
save As Boolean = False

 

 

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
Function CreateRadDock() As RadDock

 

 

Dim docksCount As Integer = CurrentDockStates.Count

 

 

Dim dock As New RadDock()

 

dock.DockMode = DockMode.Docked

dock.UniqueName = Guid.NewGuid().ToString()

dock.ID =

String.Format("RadDock{0}", dock.UniqueName)

 

dock.Title =

"Dock"

 

dock.Text =

String.Format("Added at {0}", DateTime.Now)

 

dock.Width = Unit.Pixel(300)

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 saveStateTrigger As New AsyncPostBackTrigger()

 

saveStateTrigger.ControlID = dock.ID

saveStateTrigger.EventName =

"DockPositionChanged"

 

UpdatePanel1.Triggers.Add(saveStateTrigger)

saveStateTrigger =

New AsyncPostBackTrigger()

 

saveStateTrigger.ControlID = dock.ID

saveStateTrigger.EventName =

"Command"

 

UpdatePanel1.Triggers.Add(saveStateTrigger)

 

End Sub

 

 


Protected
Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)

 

 

Dim i As Integer = 0

 

 

While i < CurrentDockStates.Count

 

 

Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i))

 

RadDockLayout1.Controls.Add(dock)

CreateSaveStateTrigger(dock)

System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)

 

End While

 

 

End Sub

 

 


Protected
Sub RadDockLayout1_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 RadDockLayout1_SaveDockLayout(ByVal sender As Object, ByVal e As DockLayoutEventArgs)

 

 

If save = True Then

 

CurrentDockStates = RadDockLayout1.GetRegisteredDocksState()

save =

False

 

 

End If

 

 

End Sub

 

 


Protected
Sub ButtonAddDock_Click(ByVal sender As Object, ByVal e As EventArgs)

 

 

Dim dock As RadDock = CreateRadDock()

 

RadDockZone1.Controls.Add(dock)

CreateSaveStateTrigger(dock)

save =

True

 

 

End Sub

 

End

 

Class

 



Help me understand what I'm missing.  Markup is identical to the one given in Telerik Example.

2 Answers, 1 is accepted

Sort by
0
Accepted
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 05 Jun 2009, 11:36 AM
Probably some of the events as Page.Load are without handlers. Try to set  AutoEventWireup="true" in the aspx, e.g.

 

<%

@ Page Language="VB" AutoEventWireup="true"..............

 

0
cbospikes
Top achievements
Rank 1
answered on 05 Jun 2009, 02:02 PM
Thanks for the reply.

You were absolutely correct.

I should have recognized that the PageInit event wasn't being handled.

I appreciate your help!
Tags
Dock
Asked by
cbospikes
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
cbospikes
Top achievements
Rank 1
Share this question
or