reference controls from within a dock's UC

2 posts, 0 answers
  1. drgorin
    drgorin avatar
    10 posts
    Member since:
    Aug 2012

    Posted 23 Apr 2009 Link to this post


    I have an aspx page that has a table of  both html checkboxes and various asp server controls (some of which are also check boxes).  I gave each of the controls an id of btn_1 thru btn_52.  btn_1 thru btn_32 are the html checkboxes.  btn_33 thru btn_52 are the server controls.  I migrated the table from the aspx to a user control.  I then placed the user control within a raddock that resides on a different aspx. I have a few javascript functions (contained in the user control ascx file) that manipulates attributes of the controls once rendered on the client.  Now that the controls are contained within a user control that is contained within a raddock, I realize that I have to do some drilling down to get a reference to the server side controls on the client. References to the HTML controls do not seem to be a problem.  For example:  I can obtain a reference to btn_1 (an html checkbox) via: var oChk = document.getElementById('btn_1').  But if I want to get a reference to btn_33 ( a server side checkbox), I have to do it with:
     var oChk = document.getElementById("RadDock1_C_ToothPicker1_" + 'btn_33'). I figured this out by "viewing the source code" after the page was rendered.  Is there a more genric way to do this?  I cannot always be certain that my instance of raddock will always be RadDock1 on any given page.  I cannot be certain that my instance of my user control will be ToothPicker1 on any given page.

    below please find a sample of my javascript from this project.


    AllClear(oButton) {




    // adult teeth




    var tt = 0;




    for (tt = 1; tt <= 32; tt++) {




    var oChk = document.getElementById('btn_' + tt)


    oChk.checked =








    // baby teeth



    tt = 0;


    for (tt = 33; tt <= 52; tt++) {




    var oChk = document.getElementById("RadDock1_C_ToothPicker1_" + 'btn_' + tt)







    oChk.checked = false;





    return false;





  2. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 27 Apr 2009 Link to this post

    You could handle the RadDock's OnClientInitialize client event and get its id, e.g.
    <%@ register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %> 
    <%@ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
    <html xmlns=""
    <head runat="server"
        <script type="text/javascript"
            function dockInit(dock, args) { 
                var dockId = dock.get_id(); 
        <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
            <telerik:RadDockLayout ID="RadDockLayout1" runat="server" > 
                    <telerik:RadDock ID="RadDock1" runat="server" OnClientInitialize="dockInit"
                                <uc1:WebUserControl ID="WebUserControl1" runat="server" />    

Back to Top