Dynamic RadDock/Client-side API

4 posts, 1 answers
  1. Ivan Queiroz
    Ivan Queiroz avatar
    31 posts
    Member since:
    Oct 2009

    Posted 23 Dec 2009 Link to this post

    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) 
     

  2. Gido Geek
    Gido Geek avatar
    28 posts
    Member since:
    Nov 2009

    Posted 24 Dec 2009 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 24 Dec 2009 Link to this post

    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.
  5. Ivan Queiroz
    Ivan Queiroz avatar
    31 posts
    Member since:
    Oct 2009

    Posted 04 Jan 2010 Link to this post

    Pero,

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

    Happy New Year!

    Ivan
Back to Top