ClientID and ID explanation

3 posts, 0 answers
  1. R2
    R2 avatar
    63 posts
    Member since:
    Sep 2007

    Posted 24 Dec 2008 Link to this post


    On page 71 on the RadControlsAJAXCourseware.pdf, it introduces the ClientID and ID properties.  I need more understanding on this.  I understand the ID property of a control, but somehow the info on this page is a little confusing to me.  Now, I noticed that this topic must be a challenging one because further down the page, a blog is listed offering more information. I'm reading the blog, but I'm still unclear as it speaks about NamingContainer (which I assume is Namespace) and other info that I'm not quite looking for right now.

    To simply ask, could you tell me exactly what this means (bolded text)?

    In some cases, "RadMenu1" will be present, but $find("RadMenu1") will return null. A safer way to find your

    RadControl is to use a server tag to output the control ClientID to the $find() method. We leave it up to the

    RadControl to figure out the correct ClientID in case the control is nested within a master page or user

    control and the ClientID wouldn't be what we expect:


    ID and ClientID



    ID property of a control identifies an ASP.NET server control. The ID is only unique within


    the current NamingContainer (page, user control, item template).



    ClientID property is unique within the entire page. The ClientID will be rendered with the


    container control, an underscore


    and the control ID. If "RadMenu1" is located directly on the


    page the two properties would be:


    ID: "RadMenu1"



    ClientID: "RadMenu1"


    If "RadMenu1" is located in a user control "WebUserControl1", the properties are:


    ID: "RadMenu1"



    ClientID: "WebUserControl1_RadMenu1"


  2. Dimo
    Dimo avatar
    8322 posts

    Posted 24 Dec 2008 Link to this post

    Hello R2,

    The text in bold means the following:

    If we have the following control on the page:


    <telerik:RadMenu ID="RadMenu1" runat="server" />

    And if we want to obtain a reference to the client-side control instance, then it is better to use


    $find("<%= RadMenu1.ClientID %>");



    This is because if RadMenu1 is placed inside another control, which implements the INamingContainer interface, the ClientID of the menu will not be the same as the server ID. The $find() Javascript method requires a valid (existing) ClientID in order to return the client-side control instance.

    I hope this makes things more clear. If not, then please refer to the ASP.NET documentation regarding naming containers, what they are and what they do.

    Best wishes,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft R3 2016 release webinar banner
  4. R2
    R2 avatar
    63 posts
    Member since:
    Sep 2007

    Posted 09 Jan 2009 Link to this post

    Thanks, I'll try what you said since I am still unclear...
Back to Top