Wildcard $find for control in ContentPlaceHolder for ASP.NET

2 posts, 0 answers
  1. Paul Robertson
    Paul Robertson avatar
    78 posts
    Member since:
    May 2010

    Posted 22 May 2012 Link to this post

    Hi there

    Can anybody assist with this problem? I have a radEditor in an ASP.NET page using a MasterPage, which as you will know, uses ContentPlaceHolder controls to hold other controls, and which also prefixes the declared control id with that of the ContentPlaceHolder in question, e.g., from a server-side id of 'myRadEditor' the client-side id would end up being something along the lines of:


    When it comes to using the client-side $find command, all of the examples I can find show the use of the following syntax:

    <%= myServerSideID.ClientID %> 

    but as far as I know, this is only valid for Javascript embedded within the <SCRIPT></SCRIPT> 'node' of the the .aspx file. However, I have a set of external Javascript script files added dynamically and programmatically, rather than specified declaratively in the aspx files in question.

    So my question is, how would I go about using the $find command to get a reference to a radEditor control, or indeed any telerik control, using a wildcard search for the server-side id (e.g., 'myRadEditor') from within an 'external' Javascript file, given that the

    <%= ... %> syntax is not available?

    Thanks very much if you can advise!


  2. Martin
    Martin avatar
    833 posts

    Posted 24 May 2012 Link to this post

    Hello Paul,

    Since you register the script dynamically, the only approach that comes into my mind is to register the control id on the page before the script is loaded. Here is how a sample code looks:


    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
            <script type="text/javascript">
                var numericTextBox = "<%= RNTB1.ClientID %>";
        <telerik:RadNumericTextBox runat="server" ID="RNTB1" Value="4"></telerik:RadNumericTextBox>
        <input type="button" onclick="MyClick();" value="Get value on the client" />


    protected void Page_PreRender()
        ScriptManager.RegisterClientScriptInclude(Page, Page.GetType(), "DynamicScript", "Scripts/JScript.js");


    function MyClick()

    I hope this helps.

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top