Dynamic Dock - Telerik Example

3 posts, 1 answers
  1. cbospikes
    cbospikes avatar
    16 posts
    Member since:
    May 2007

    Posted 04 Jun 2009 Link to this post

    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. Answer
    Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 05 Jun 2009 Link to this post

    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"..............

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. cbospikes
    cbospikes avatar
    16 posts
    Member since:
    May 2007

    Posted 05 Jun 2009 Link to this post

    Thanks for the reply.

    You were absolutely correct.

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

    I appreciate your help!
Back to Top