Trying to close RadDock in Javascript

2 posts, 0 answers
  1. Rick
    Rick avatar
    1 posts
    Member since:
    Sep 2010

    Posted 15 Feb 2011 Link to this post

    I have a module within DotNetNuke that contains a RadMenu and a RadDock.  Items in the menu correspond to some of the RadDocks.  For example, one of the RadDocks is named Dock_MyTasks.  I can pull that name from the RadMenuItem value field.  But when I try to use that name to $Find the Dock control I have problems.  First, DNN adds to the Dock_MyDocks name like this ...



    I get around that by calling a Javascript function that returns a control containing the name Dock_MyTasks.  But, when I look at the running HTML, there are multiple HTML elements that contain the name Dock_MyTasks.  They are suffixed with _T, _C, _ClientState.  Here's the JavaScript I'm trying to use.  Everyhing seems to execute just fine until I call the GetClientId function.  What am I doing wrong?











    function miClicked(sender, e) {

    var MenuItem = e.get_item();

    var DockName = MenuItem.get_value();

    var dock = GetClientId(DockName);

    var isClosed = dock.get_closed();


    MenuItem.Selected = !MenuItem.Selected;



    // Gets the ASP.NET generated control ID


    function GetClientId(controlId) {

    var count = document.forms[0].length;

    var i = 0;

    var aspControlId;

    for (i = 0; i < count; i++) {

    aspControlId = document.forms[0].elements[i].id;

    pos = aspControlId.indexOf(controlId);

    if (pos >= 0) break;



    return document.forms[0].elements[i];




  2. Pero
    Pero avatar
    1156 posts

    Posted 17 Feb 2011 Link to this post

    Hi Rick,

    The easiest way to find the correct dock, would be to store its ClientID in the corresponding RadMenuItem. If this is not possible, modify your GetClientId method to check whether the className contains the "RadDock" string. The modified code will look like the following:
    function GetClientId(controlId)
        var count = document.forms[0].length;
        var aspControlId;
        for (var i = 0; i < count; i++)
            var currentElement = document.forms[0].elements[i];
            aspControlId =;
            pos = aspControlId.indexOf(controlId);
            if (pos >= 0 && currentElement.className.indexOf("RadDock") != -1)
        return aspControlId;

    Now, if you want to get a reference to the dock, simply use the $find method and pass the RadDock's client id.

    Kind regards,
    the Telerik team
Back to Top