how to access user control by javascript

2 posts, 0 answers
  1. Muhammad
    Muhammad avatar
    4 posts
    Member since:
    Mar 2012

    Posted 04 Apr 2012 Link to this post

    i have a user control with rad tool bar button like this

    <telerik:RadToolBar ID="RadToolBar1" Runat="server" 
    EnableRoundedCorners="True" EnableShadows="True" Width="940px" 
    onbuttonclick="RadToolBar1_ButtonClick" onunload="RadToolBar1_Disposed">
    <Items>
    <telerik:RadToolBarButton CommandName="btn" Text="Add" ImageUrl="../Images/Add.png" 
    ImagePosition="AboveText" />
    <telerik:RadToolBarButton Text="Update" ImageUrl="../Images/Edit.png" ImagePosition="AboveText" />
    <telerik:RadToolBarButton Text="Delete" ImageUrl="../Images/Delete.png" 
    ImagePosition="AboveText" />
    <telerik:RadToolBarButton Text="Refresh" ImageUrl="../Images/Refresh.png" ImagePosition="AboveText" />
    <telerik:RadToolBarButton Text="Print" ImageUrl="../Images/Print.png" 
    ImagePosition="AboveText" Enabled="False" />
    <telerik:RadToolBarButton Text="Close" ImageUrl="../Images/Close.png" 
    ImagePosition="AboveText" />
    <telerik:RadToolBarButton Text="Save As" ImageUrl="../Images/SaveAs.png" 
    ImagePosition="AboveText" />
    <telerik:RadToolBarButton Text="Itemtemplate">
    <ItemTemplate>
    <div id="loginAarea" style="margin-left:150px" >
    <table style="margin-left: -50px;" >
    <tr>
    <td >
    <telerik:RadTextBox ID="txtUserName" runat="server" Label="Added By" 
    Width="240" Height="16" Enabled="false" Font-Bold="True" ></telerik:RadTextBox>
    </td>
    <td>
    <telerik:RadTextBox ID="txtLastUserName" runat="server" 
    Label="Last Updated By" Width="240" Height="16" Enabled="false" 
    Font-Bold="True" ></telerik:RadTextBox>
    </td>
    </tr>
    <tr>
    <td>
    <telerik:RadTextBox ID="txtLoginDate" runat="server" Label="Date:" 
    Width="240" Height="16" Enabled="false" Font-Bold="True" ></telerik:RadTextBox>
    </td>
    <td>
    <telerik:RadTextBox ID="txtLastLoginDate" runat="server" Label="Date:" 
    Width="240" Height="16" Enabled="false" Font-Bold="True" ></telerik:RadTextBox>
    </td>
    </tr>
    </table>
    </div>
    </ItemTemplate>
    </telerik:RadToolBarButton>

    </Items>
    </telerik:RadToolBar>

    i add the rad tool bar with place holder on content page like this

    Page.LoadControl("MenuStyle1.ascx");
    Spinner1 = (ASP.MenuStyle1)LoadControl("MenuStyle1.ascx");
    RadToolBar tlbar = (RadToolBar)Spinner1.FindControl("RadToolBar1");
    place.Controls.Add(tlbar);

    <asp:PlaceHolder ID="place" runat="server"></asp:PlaceHolder>

    now i want to access the radtoolbar using javascript how i do that

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Apr 2012 Link to this post

    Hello Muhammed,

    Try setting the ClientIDMode property of RadToolBar to Static and access the Toolbar like
    JS:
    document.getElementById("ctl00_MainContent_RadToolBar1")

    Thanks,
    Princy.
Back to Top