Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Beta Forum > How to get ClientObject of command template buttons?

Not answered How to get ClientObject of command template buttons?

Feed from this thread
  • Ankit avatar

    Posted on Feb 6, 2012 (permalink)

    Hi,

    I am having some linkbuttons in commandtemplate as following.
    I want to access linkbutton at clientside so i can disable or enable .
    <CommandItemTemplate>
                                                    <div style="padding: 3px 3px;">
                                                        <table>
                                                            <tr>
                                                                <td>
                                                                    <asp:LinkButton ID="btnAddUserGroup" runat="server" CommandName="InitInsert" Visible='<%# rgManageUserGroupParameters.EditIndexes.Count == 0 && !rgManageUserGroupParameters.MasterTableView.IsItemInserted %>'
                                                                        ClientIDMode="Static">
                                                                        <img style="border: 0px; vertical-align: middle;" alt="" src="../Images/NewEnable2.png" />
                                                                          
                                                                        <asp:Literal ID="ltlAddUser" runat="server" Text="Add"></asp:Literal>
                                                                    </asp:LinkButton>                                          
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                </CommandItemTemplate>
    Please suggest for the same.I have checked with the forum but all the information is related to access button of Radtoolbar buttons present in commandtemplate.

    Reply

  • Antonio Stoilkov Antonio Stoilkov admin's avatar

    Posted on Feb 7, 2012 (permalink)

    Hello Ankit,

    You can achieve your scenario by following the provided code below. Note that the getElementsByClassName is only a helper function and the $telerik.findElement call is getting the link element. Note that the ClientIDMode is prone to causing problems with Template controls, so I advise that you remove it from the definition.

    document.getElementsByClassName = function (cl)
    {
        var retnode = [];
        var myclass = new RegExp('\\b' + cl + '\\b');
        var elem = this.getElementsByTagName('*');
        for (var i = 0; i < elem.length; i++)
        {
            var classes = elem[i].className;
            if (myclass.test(classes)) retnode.push(elem[i]);
        }
        return retnode;
    }
    var link = $telerik.findElement(document.getElementsByClassName("rgCommandRow")[0], "btnAddUserGroup");
    Greetings,
    Antonio Stoilkov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Beta Forum > How to get ClientObject of command template buttons?