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

Dynamically created Docks and ClientCommands - Bug??

1 Answer 76 Views
This is a migrated thread and some comments may be shown as answers.
Joe Labate
Top achievements
Rank 1
Joe Labate asked on 03 Jun 2010, 11:33 PM

I have a page that creates docks programmatically and assigns a custom command to each dock. The custom command uses the OnClientCommand property to set the client-side function that executes when the command is clicked.

The first problem I am having, is that the client-side function is being automatically executed when the docks are loaded. I need the function to be executed only when the user clicks the custom command button.

The second problem is that when I click the custom command button, I get the following script run-time error within the script manager WebResource.axd:

Message: Object doesn't support this property or method
Line: 6
Char: 29366
Code: 0

I am running Telerik RadControls version 2010-1-415. I am using the 3.5 framework .dll inside a 3.5 framework web application using Visual Studio 2010 Professional.

Here is the Web Form code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadDockTest.aspx.cs" Inherits="TelerikTest.RadDockTest" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
<html xmlns="">  
<head runat="server">  
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">  
        <script language="javascript" type="text/javascript">  
        function CustomCommandClick(dockID) {  
            alert("Custom command clicked for dock #" + dockID);  
        <asp:UpdatePanel ID="upRadDocks" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">  
                <asp:AsyncPostBackTrigger ControlID="btnLoadDocks" EventName="Click" /> 
                <asp:Button ID="btnLoadDocks" runat="server" Text="Load Docks" OnClick="btnLoadDocks_Click" /> 
                <telerik:RadDockLayout ID="rdlRadDocks" runat="server">  
                    <telerik:RadDockZone ID="rdzDynamicDocks" runat="server" Width="800" MinHeight="200">  

Here is the class code:

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Telerik.Web.UI;  
namespace TelerikTest  
    public partial class RadDockTest : System.Web.UI.Page  
        protected void Page_Load(object sender, EventArgs e)  
        /// <summary>  
        /// Creates a new rad dock  
        /// </summary>  
        /// <param name="id">The dock ID</param>  
        /// <returns>A RadDock control</returns>  
        private RadDock CreateRadDock(int id)  
            //Create the new dock  
            RadDock     dock                    = new RadDock();  
            dock.DockMode                       = DockMode.Docked;  
            dock.UniqueName                     = "rd" + id.ToString();  
            dock.ID                             = dock.UniqueName;  
            dock.Width                          = Unit.Pixel(800);  
            //Clear dock commands  
            //Add the dock commands  
            DockCommand command                 = new DockCommand();  
            command.Name                        = "Custom Command";  
            command.Text                        = "Custom Command";  
            command.OnClientCommand             = "CustomCommandClick('" + dock.UniqueName + "');";  
            return dock;  
        /// <summary>  
        /// Load Docks button click event  
        /// </summary>  
        /// <param name="sender"></param>  
        /// <param name="e"></param>  
        protected void btnLoadDocks_Click(object sender, EventArgs e)  
            //Load the docks  
            for(int i = 0; i <= 4; i++)  
                //Create a new dock  
                RadDock dock = this.CreateRadDock(i);  
                //Add the new dock to the dock zone  

1 Answer, 1 is accepted

Sort by
Joe Labate
Top achievements
Rank 1
answered on 07 Jun 2010, 07:56 PM
This issue is resolved. I made the mistake of assuming that the OnClientCommand property was simply a call to a javascript function that you specify. In fact, this is a client-side delegate that requires the signature of a delegate.

Changing the signature of the client-side function to "function CustomCommandClick(dock, sender)" and the value of the OnClientCommand property to "CustomCommandClick" fixed the issue.

Works like a charm now.


Asked by
Joe Labate
Top achievements
Rank 1
Answers by
Joe Labate
Top achievements
Rank 1
Share this question