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

Forums / Developing with Sitefinity / Question about links in user controls

Question about links in user controls

15 posts, 0 answered
  1. Josh
    Josh avatar
    19 posts
    Registered:
    24 Jun 2009
    24 Jul 2009
    Link to this post
    Ok, so this may be a little novice, but I am stuck on this one.  I have multiple user controls I created through VS2008 that I am dropping into my pages.  One of the controls is used on multiple pages that are on different tiers of the site.  For example it is used on:

    -page 1
        *subpage 1
        *subpage 2
    -page 4
        *subpage 2

    Now, I have some links to other pages within the application in this control.  What is the best way to create these <a> tags in the code?  Do i expose them as public properties and then link them in the UI of sitefinity?  Is that the easiest, safest way?  THanks for any help!

    Josh
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Jul 2009
    Link to this post
    Hi Josh,

    A good way is using of DynamicHyperlink control where you can pass the id of a page. Therefore changing the name or location of a cms page will not break the links.
    Using the properties is a good way because you will be able to change the links in edit mode instead of hardcoding them.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Josh
    Josh avatar
    19 posts
    Registered:
    24 Jun 2009
    28 Jul 2009
    Link to this post
    Thanks for the reply Ivan...

    What would be the best way to get that control into the Visual Studio IDE so i can access it in my user control?  Thanks for the help!

    josh
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Jul 2009
    Link to this post
    Hello Josh,

    The control is located under Telerik.Cms.Engine assembly, namspace Telerik.Cms.Engine.WebControls. You can register a new tag prefix, assemble and namespace. Then declare the control in your user control.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Michael
    Michael avatar
    7 posts
    Registered:
    07 Dec 2010
    15 Feb 2011
    Link to this post
    When I try to do this in my control as such:

    <sf:DynamicHyperLink runat="server" ID="DH1" PageId="4109f960-7962-44c4-9a90-f4017ba99fd1" Text="Testing" />

    I get the error  'GuidTypeConverter' is unable to convert 'System.Guid' to 'System.ComponentModel.Design.Serialization.InstanceDescriptor'.  The error doesn't happen if the PageId property in code-behind instead of the ascx markup.  This is with SF 3.7.2136.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Feb 2011
    Link to this post
    Hi Michael,

    Please take a look at this post

    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
  7. Michael
    Michael avatar
    7 posts
    Registered:
    07 Dec 2010
    16 Feb 2011
    Link to this post
    Thanks for the quick reply Ivan.  In the post you linked me to, he was using the DHL control from the Telerik.Cms assembly which is marked as deprecated.  The one mentioned here, from Telerik.Cms.Engine, is its replacement.

    Just to make sure there's nothing in my project that could be responsible, I made a completely new, blank project and uploaded the control whose code is below. On my end, I'm seeing the deprecated control rendering the link correctly if PageId is set in code-behind, but the newer control never renders the link (i.e. it will render <a id="ctl00_Navigation_ctl00_DHL1">Text</a> with no href).  With either control, setting the PageId property in markup results in that exception.

    We're making a mega menu based off this example so it's strictly a user control.  Since it's inside a template it'll be more difficult to set the PageId properties through code.

    Are those controls not intended for use in user controls, or am I missing something?  I'm running the .NET 4 version of SF, could that have anything to do with it?

    Here is the markup for my test control:

    <%@ Control Language="C#" %>
    <%@ Register TagPrefix="sfOld" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms" %>
    <%@ Register TagPrefix="sfNew" Namespace="Telerik.Cms.Engine.WebControls" Assembly="Telerik.Cms.Engine" %>
     
    <%--
      The deprecated control will render the link properly when PageId is assigned in code-behind.
      The other one won't.
    --%>
    <% DH1.PageId = new Guid("cc334673-f33f-4add-a5da-8e035f01f04a"); %>
    <% DH2.PageId = new Guid("cc334673-f33f-4add-a5da-8e035f01f04a"); %>
    <sfOld:DynamicHyperLink runat="server" ID="DH1" UseAsDynamicLink="true" Text="Home with deprecated DHL" />
    <br />
    <sfNew:DynamicHyperLink runat="server" ID="DH2" UseAsDynamicLink="true" Text="Home with new DHL" />
     
     
    <%--
      Either control will throw an exception when PageId is set in markup.
    --%>
    <%--
    <sfOld:DynamicHyperLink runat="server" ID="DH3" UseAsDynamicLink="true" PageId="cc334673-f33f-4add-a5da-8e035f01f04a" Text="Home with deprecated DHL" />
    <br />
    <sfNew:DynamicHyperLink runat="server" ID="DH4" UseAsDynamicLink="true" PageId="cc334673-f33f-4add-a5da-8e035f01f04a" Text="Home with new DHL" />
    --%>
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Feb 2011
    Link to this post
    Hi Michael,

    It is not possible to use the PageID in the markup. You should set it from the server - Page_Load or another event. There would not be a problem to do this since you can access all server controls from the server side using recursion and looping through the controls collection when this is necessary.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
  9. David
    David  avatar
    12 posts
    Registered:
    03 Nov 2011
    29 Nov 2011
    Link to this post
    I have created navigation menu using RadMenu however how to create DynamicHyperlink control?

  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Nov 2011
    Link to this post
    Hello David ,

    The DynamicHyperLink is part of our assembly, you don;t need to create it. Could you elaborate some more about your goal?

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. David
    David  avatar
    12 posts
    Registered:
    03 Nov 2011
    29 Nov 2011
    Link to this post
    I created navigation menu using RadMenu.
    I need bind all url or pages to appear to my navigation menu instead of "Build Radmenu"
    for example, when i create navigation menu build in sitefinity, it will create all main and child menu automatically depends on number of my pages.
    so is RadMenu implement same concept?
    if it is, i like to know the settings that i need to change.
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Nov 2011
    Link to this post
    Hello David ,

    You can bind the RadMenu to SiteMapDataSouce or you can using the API - CmsManager class and its methods to bind the control to all pages you want.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. David
    David  avatar
    12 posts
    Registered:
    03 Nov 2011
    29 Nov 2011
    Link to this post
    CmsManager cmsManager = new CmsManager();
    Telerik.Cms.Web.UrlHelper.HomePageInfo homePage = UrlHelper.HomePage;
    ICmsPage page = (ICmsPage)cmsManager.GetPage(homePage.ID)

    so is this simple code will import main and sub main pages that I created from sitefinity to Radmenu navigation list w/o build radmenu lists?
    if so do i create a new ui control for this or where do i input above code?

  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Nov 2011
    Link to this post
    Hello David ,

    Please take a look at the links below

    http://www.sitefinity.com/help/developer-manual/pages-api-overview.html

    http://www.telerik.com/help/aspnet-ajax/menu-data-binding-overview.html

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. David
    David  avatar
    12 posts
    Registered:
    03 Nov 2011
    30 Nov 2011
    Link to this post
    is there a data binding video bind to existing sql database?
Register for webinar
15 posts, 0 answered