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

Dynamic RadDock/Client-side API

3 Answers 131 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Ivan Queiroz
Top achievements
Rank 1
Ivan Queiroz asked on 23 Dec 2009, 03:07 PM
The following works fine:

<telerik:raddock id="RadDock1" runat="server"     
                            onclientdockpositionchanged="OnClientDockPositionChanged" title="RadDock1" text="RadDock1">    
</telerik:raddock>    
  
function OnClientDockPositionChanged(dock) {  
  
    var selectedFields = $find('<%= RadDockZoneSelectedFields.ClientID %>');  
    var totalFields = selectedFields.get_docks().length;  
    var fieldArray = selectedFields.get_docks();  
      
    for (var i =0; i < totalFields; i++) }  
        alert(fieldArray[i].get_uniqueName());  
    }  
}  

But, if I create a raddock dynamically (see code below) and try to attach a client-side event to it, I get the following javascript error: "OnClientDockPositionChanged is not defined." Why?

        Dim dock As New RadDock() 
 
        dock.DockMode = DockMode.Docked 
        dock.OnClientDockPositionChanged = "OnClientDockPositionChanged" 
        dock.CommandsAutoPostBack = False 
        dock.EnableViewState = False 
        dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None 
        dock.AutoPostBack = False 
        dock.UniqueName = Uniquename
        dock.ID = "dockid" 
        dock.Title = "dock title" 
        dock.Width = Unit.Pixel(300) 
 

3 Answers, 1 is accepted

Sort by
0
Gido Geek
Top achievements
Rank 2
answered on 24 Dec 2009, 09:13 AM
Dear Ivan,

I'll try to help you the best I can. But first I'd like to know where in the lifecycle you are trying to create the RadDock dynamically ?

Merry X-mas,
Gido
0
Accepted
Pero
Telerik team
answered on 24 Dec 2009, 03:42 PM
Hello Ivan,

I am not aware of your specific scenario, but I reproduced the behavior by dynamically creating RadDock and RadDockZone controls and adding them to a WebUserControl. The UserControl itself is added dynamically on a Button Click. At first, the client-code was placed in the markup of the UserControl and I was getting the same error - the handler method is not defined. To overcome the problem I registered the script dynamically from the server using the ScriptManager.RegisterStartupScript method.

The project is attached to the thread.

Regards,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ivan Queiroz
Top achievements
Rank 1
answered on 04 Jan 2010, 07:38 PM
Pero,

Thank you so much! Registering the script does the trick!

Happy New Year!

Ivan
Tags
Dock
Asked by
Ivan Queiroz
Top achievements
Rank 1
Answers by
Gido Geek
Top achievements
Rank 2
Pero
Telerik team
Ivan Queiroz
Top achievements
Rank 1
Share this question
or