This is a migrated thread and some comments may be shown as answers.

register DockPositionChanged for codebehind dynamically

1 Answer 77 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Juan
Top achievements
Rank 1
Juan asked on 22 Mar 2012, 01:56 PM
hi, i'm create a RadDock dynamically of this form:

Protected Function creardock() As RadDock
        Dim newdock As New RadDock

        newdock.UniqueName = Guid.NewGuid().ToString().Replace("-", "a")
        newdock.ID = String.Format("RD{0}", newdock.UniqueName)
        newdock.EnableAnimation = True
        newdock.EnableDrag = True
        newdock.DockMode = DockMode.Docked
        newdock.DockHandle = DockHandle.Grip
        newdock.Resizable = False
        newdock.Width = Unit.Percentage(50)
        newdock.AutoPostBack = True
        newdock.Collapsed = False
        newdock.Skin = "Black"
        AddHandler newdock.DockPositionChanged, New DockPositionChangedEventHandler(AddressOf RadDock_DockPositionChanged)

        Return newdock
    End Function


this is a function that i need register for each raddock created:

    Protected Sub RadDock_DockPositionChanged(ByVal sender As Object, ByVal e As DockPositionChangedEventArgs)
        Dim docksel As RadDock = DirectCast(sender, RadDock)
        docksel.DockZoneID = e.DockZoneID
        docksel.Index = e.Index

        lbl.Text = "dock_zone_obj: " & docksel.DockZoneID & " - dock_zone_des: " & e.DockZoneID & "<br />" & _
                   "dock_index_obj: " & docksel.Index & " - dock_index_des: " & e.Index
    End Sub


Each raddock that is returned for the function creardock(), i need add to a raddockzone that too is created dynamically, the problem is that the event RadDock_DockPositionChanged not being registered, the addition to the raddockzone is as follows:

Dim mizona As RadDockZone = crearradzone()

Dim midock As RadDock = creardock()
 mizona.Controls.Add(midock)

this is the function that return the new raddockzone

 Protected Function crearradzone() As RadDockZone
        Dim newraddockzone As New RadDockZone()
        newraddockzone.MinWidth = Unit.Percentage(98)

        Return newraddockzone
    End Function

note that the creation of the Raddockzone and the Raddock depend on a dynamic creation of tables rows and columns have many records in a DB, the only fixed in the file .aspx is a RadDockLayout and a panel which I add the table or tables dynamically created

help me, i need know if there is any mistake in any function in my code, thanks.

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 27 Mar 2012, 10:17 AM
Hello Juan,

From the source code you provided I can see that you set the ID and the UniqueName of the dock by generating a GUID:
      newdock.UniqueName = Guid.NewGuid().ToString().Replace("-", "a")
      newdock.ID = String.Format("RD{0}", newdock.UniqueName)

Do you always generate a new ID when creating the dock dynamically? If this is the case then the RadDockLayout will not maintain the dock state correctly, and the server-side events of the dock might not be raised. Please note that the RadDock must have one and the same ID and UniqueName throughout the application's life-cycle.
So my recommendation is to have a separate method that will be used to create the RadDock from the state. As a reference you could use our MyPortal demo. Note that we have two functions for creating docks:
        Private Function CreateRadDockFromState(state As DockState) As RadDock
        Private Function CreateRadDock() As RadDock


Kind regards,
Pero
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Dock
Asked by
Juan
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or