More in this section

Forums / Developing with Sitefinity / Problem with asp hyperlinks

Problem with asp hyperlinks

2 posts, 1 answered
  1. Keith
    Keith avatar
    67 posts
    13 Sep 2010
    12 Oct 2010
    Link to this post
    I have a customized news control that I am trying to modify the control template.  We have added a "URL" metafield (ShortText) and I am trying to access this field using an asp:hyperlink tag.  However, when I put the following into the template:
    <asp:Hyperlink ID="URL" runat="server">Link</asp:Hyperlink>
    The entire URL shows up (not the word "Link") and I can't click on the link!
    I have also tried:
    <asp:Hyperlink ID="URL" runat="server" Text="Link />
    which gives me the same result.

    There is another hyperlink in the template which was there before we modified it:
    <asp:HyperLink ID="tagLink" runat="server" />
    and it works fine.

    Any help would be greatly appreciated
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    01 Feb 2016
    12 Oct 2010
    Link to this post
    Hello Keith,

    Thank you for using our services.

    The meta fields' values are applied to the Text property of an IText control with the same ID in the control template. For links you would have to take a little bit different approach. In the control template for the news list you have to subscribe to the ItemDataBound event of the repeater control and set the url as follows:
    <script runat="server" type="text/C#">
        protected void Page_Load()
            repeater.ItemDataBound += new RepeaterItemEventHandler(repeater_ItemDataBound);
        void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                HyperLink URL = e.Item.FindControl("URL") as HyperLink;
                URL.NavigateUrl = ((Telerik.Cms.Engine.IContent)e.Item.DataItem).GetMetaData("URL") as string;

    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
2 posts, 1 answered