More in this section

Forums / Developing with Sitefinity / Dynamic Hyperlink Access

Dynamic Hyperlink Access

5 posts, 1 answered
  1. Shawn Davis
    Shawn Davis avatar
    81 posts
    Registered:
    13 Oct 2012
    07 Jun 2010
    Link to this post
    I'd like to set some properties for a dynamic hyperlink placed on a page through the CMS page designer from a home made user control.  I really just want to make it visible or not based on criteria.  I've tried a few things that aren't working.  Is this possible, and if so can you give me some code that would do it?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Jun 2010
    Link to this post
    Hi Shawn Davis,

    Could you elaborate some more about what you want to achieve and how the control should behave.

    Sincerely yours,
    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. Shawn Davis
    Shawn Davis avatar
    81 posts
    Registered:
    13 Oct 2012
    08 Jun 2010
    Link to this post
    My user control will be in one content area.  The DHL will be in another content area on the same page.  I want to check for its existence based upon the text and then set it visible or not based upon  some criteria that I will retieve from a db.

    Can I use findcontrol?  I tried but it didn't work.

    Thanks,
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Jun 2010
    Link to this post
    Hello Shawn Davis,

    You have to loop through the control collection, get the control and its property and check it. Here is a sample code that illustrates this

    Telerik.Cms.ICmsPage page = (ICmsPage)cmsManager.GetPage(pageID);
            foreach (Telerik.Cms.ICmsWebControl webCtrl in page.Staged.Controls;)
            {
                if (webCtrl.ContainerID == "SomeName" && webCtrl.ControlType == typeof(DynamicHyperLink))
                {
                    DynamicHyperLinkgcCtrl dhlControl = webCtrl.LoadControl() as DynamicHyperLink;
                   if(dhlControl !=null)
                       {
                          id(!String.IsNullOrEmpty(dhlControl.Text))
                              {
                                 // do something here     
                              }
                       }
                }
           }


    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.
    Answered
  5. Shawn Davis
    Shawn Davis avatar
    81 posts
    Registered:
    13 Oct 2012
    08 Jun 2010
    Link to this post
    This looks like it will help.  Thank you very much!
Register for webinar
5 posts, 1 answered