+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Accessing a control property programmatically from its control template

Accessing a control property programmatically from its control template

6 posts, 0 answered
  1. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    11 Oct 2010
    Link to this post
    Hi,

    I made a custom ascx template to be used with the DownloadList control and I need a way to programmatically access the ID of the control from within the ASP in the ascx file.  Is this at all possible?

    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 Oct 2010
    Link to this post
    Hi Keith,

    The ascx file you have created is just a template of DownloadList control.  You can get the control ID by looping through the controls collection and find a control of type DownloadList, then get its ID.

    Otherwise you need to inherit from the class and get its ID or ClientID property. The ID property or ClientID property comes from the base class which is CompositeControl.

    Greetings,
    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
  3. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    11 Oct 2010
    Link to this post
    So how would I do this within the ascx file? The page that the control will sit on has multiple DownloadList controls...
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    11 Oct 2010
    Link to this post
    Hi Keith,

    You can use some other property to identify the exact control you are looking for or inherit from DownloadList as suggested in the previous reply to you. You case is the same as finding multiple standard ASP.NET controls, like Login, TextBox, Menu, SiteMapPath etc.

    Best wishes,
    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
  5. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    11 Oct 2010
    Link to this post
    So....inherit from DownloadList? Can you elaborate a little more? I am not trying to find multiple controls; I just want to have the control template reference its control if that makes sense.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    12 Oct 2010
    Link to this post
    Hi Keith,

    The control template does not know about the control. The relation is Control - >Template. From the template you can only access DataItem object of the repeater used for showing your items.

    Greetings,
    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
Register for webinar
6 posts, 0 answered