More in this section

Forums / Developing with Sitefinity / Client ID in User control

Client ID in User control

8 posts, 1 answered
  1. Siddesh Kapadi
    Siddesh Kapadi avatar
    239 posts
    Registered:
    09 Oct 2009
    24 May 2010
    Link to this post
    Hi,
    I have been developing the user controls in sitefinity for JQuery Navigation. I need the Hyperlink control ClientID, I am dynamically creating the control. When I use the clientD property for the control, It inturn returns me the ID of the hyperlink that is created. Can anyone help me in this. Very Urgent!!!

    Thanks in advance.
  2. George
    George  avatar
    204 posts
    Registered:
    05 Sep 2006
    24 May 2010
    Link to this post
    Hi there,

    For JQuery and ClientID problem use the following selector $("[id$='_controlID']") note that the _ will handle selecting the control with the proper ID

    Best,

    G
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 May 2010
    Link to this post
    Hello Siddesh Kapadi,

    If you call the l.ID or l.ClientID from the server you should get the correct results. It also depends on how you build the menu navigation and how you are trying to get the HyperLink CleintID. The Hyperlink renders "a" tags, so you could get all tags from a given container and then use each to get the ClientID

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  4. Siddesh Kapadi
    Siddesh Kapadi avatar
    239 posts
    Registered:
    09 Oct 2009
    24 May 2010
    Link to this post
    Hi Ivan,

    Yes, I am using the ClientID property to get the client ID of the Control. I didnot understand your statement about how I build the menu navigation.
    I have to assign the element to the javascript function and then register the script on the page.
    Below is the process to do build the menu. It is driven using CSS.

    I create a table, tablerow, table cell. Then I create a hyperlink to add on the menu.
    Once I add the link to the cell, I create a string builder to register the string as javscript.
    Once this is done I add the table to the place holder in my page.

    This should ideally give me the client ID of the control, but in this case it is not.

    Please Help!!!
  5. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 May 2010
    Link to this post
    Hi Siddesh Kapadi,

    If the control which you are trying to get by Client ID is nested inside some other composite control calling $find("<%= Control.ClientID %>") will not help. In this case what you can do is to add a HiddenField control on the top of you control hierarchy and then on page load you will set your hidden field value to contain the ClientID of your control. After that you will use $find("") with the value from the hidden field.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Siddesh Kapadi
    Siddesh Kapadi avatar
    239 posts
    Registered:
    09 Oct 2009
    24 May 2010
    Link to this post
    Hello Radoslav,
    The code snippet is attached with this reply. please look at the item squared in red. This is where I try to get the clientID of the control. This code is called in Page_load  event.
    Please Help!!!
  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 May 2010
    Link to this post
    Hello Siddesh Kapadi,

    It is not possible to get the client ID of a control before it has been added to the controls collection on the page. As far as I see from your code snippet you add your hyperlink to a table, which OK. However this table is not added to the controls collection of the page when you are trying to get the Client ID of the hyperlink. You should first add the table to the page and then work with Client IDs.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  8. Siddesh Kapadi
    Siddesh Kapadi avatar
    239 posts
    Registered:
    09 Oct 2009
    24 May 2010
    Link to this post
    Hi Radoslav,

    Thanks to Team Telerik for all the help and support. just uploading the working prototype(img) so that it can act as a reference to other users of sitefinity.

    Once again Thanks.

    Regards,
    Siddesh Kapadi
Register for webinar
8 posts, 1 answered