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

Forums / Bugs & Issues / Changing Hyperlink Text in Public View

Changing Hyperlink Text in Public View

7 posts, 1 answered
  1. Emmanuel
    Emmanuel avatar
    5 posts
    Registered:
    13 Oct 2010
    14 Jan 2011
    Link to this post
    I've created my own Provider based from the News with its own meta fields.  One of the metafield is a Hyperlink the user can paste a URL to.

    In my public view, I would like for the hyperlink tag to use the URL but, I want it to display a different text.  I tried everything, putting control inside the <asp:HyperLink> tag, set the Text property on the control itself.  It doesn't seem to matter.

    Thanks,
    Manny 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Jan 2011
    Link to this post
    Hello Emmanuel,

    Can you show the metakey declaration and how you have declared the control that is supposed to show the value of the metakey in your template?

    All the best,
    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. Emmanuel
    Emmanuel avatar
    5 posts
    Registered:
    13 Oct 2010
    17 Jan 2011
    Link to this post
    Ivan,

    Heres my metakey: (the field in question is "Article_URL")
    <add key="HKS_Press_Coverage.Title" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>
    <add key="HKS_Press_Coverage.Article_Title" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>
    <add key="HKS_Press_Coverage.Article_URL" valueType="ShortText" visible="True" searchable="True" sortable="False" defaultValue=""/>
    <add key="HKS_Press_Coverage.Summary" valueType="LongText" visible="True" searchable="True" sortable="True" defaultValue=""/>
    <add key="HKS_Press_Coverage.Publication_Month" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>
    <add key="HKS_Press_Coverage.Publication_Year" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>
    <add key="HKS_Press_Coverage.Publication_Date" valueType="DateTime" visible="True" searchable="True" sortable="True" defaultValue="#Now"/>
    <add key="HKS_Press_Coverage.Expiration_Date" valueType="DateTime" visible="True" searchable="True" sortable="True" defaultValue="#Max"/>
    <add key="HKS_Press_Coverage.Thumbnail" valueType="ShortText" visible="True" searchable="False" sortable="False" defaultValue=""/>
    <add key="HKS_Press_Coverage.Category" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""></add>

    Heres a snippet of my Admin\ControlTemplates\HKS_Press_Coverage\NewsItemNew.ascx
    <h3>Additional Info</h3>
    <fieldset class="set">
      <ol class="setIn">
        <li>
            <asp:Label ID="Label5" AssociatedControlID="Article_Title" runat="server">Article Title</asp:Label>
            <asp:TextBox ID="Article_Title" Text="" runat="server" MaxLength="250"></asp:TextBox>
            <p class="example">Article Title</p>
        </li>
        <li>
            <asp:Label ID="Label9" AssociatedControlID="Article_URL" runat="server">Article URL</asp:Label>
            <asp:TextBox ID="Article_URL" Text="" runat="server" MaxLength="250"></asp:TextBox>
            <p class="example">Select the Article's URL</p>
        </li>
        <li>
            <asp:Label ID="Label10" AssociatedControlID="Publication_Month" runat="server">Publication Month</asp:Label>
            <div style="float:left; width:100px;">
                <asp:TextBox ID="Publication_Month" Text="" runat="server" MaxLength="20" Width="75px"></asp:TextBox>
            </div>
            <div style="float:left; width:260px;">
                <asp:Label ID="Label11" AssociatedControlID="Publication_Year" runat="server">Publication Year</asp:Label>
                <asp:TextBox ID="Publication_Year" Text="" runat="server" MaxLength="4" Width="50px"></asp:TextBox>
            </div>
            <div style=" clear:both; height:0px;"></div>
            <p class="example"> </p>
        </li>

    and heres a snippet of my view control:
    <ItemTemplate>       
        <li>
            <div style="width:140px; height:140px; float:left; vertical-align:top; margin:-13px 0 0 0;">
                <asp:PlaceHolder ID="ThumbnailHolder" runat="server">
                    <asp:Image ID="Thumbnail" runat="server" Width="140px" Height="140px" />
                    </asp:HyperLink>
                </asp:PlaceHolder>
            </div>
            <div style="width:10px; height:140px; float:left;"> </div>
            <div style="width:360px; height:140px; float:left; vertical-align:top;"
                <div class="sf_newsCoverageTitle">
                    <asp:Label ID="Title" runat="server" style="width:20px;"></asp:Label>  (
                    <asp:Label ID="Publication_Month" runat="server" style="width:95px; margin: 0 0 0 -6px;"></asp:Label>
                    <asp:Label ID="Publication_Year" runat="server" Width="35px" style="margin: 0 0;"></asp:Label>)
                </div>
     
                <asp:HyperLink ID="Article_URL" runat="server" NavigateUrl="<%=this.Text%>">
                    <asp:Label ID="Article_Title" runat="server" CssClass="article_title" Width="360px"></asp:Label>
                </asp:HyperLink>
     
                <p>
                    <asp:Label ID="Summary" runat="server" CssClass="NewsSummary" Width="360px"></asp:Label>
                </p>
            </div>
     
            <div style="clear:both;"></div>
     
            <br />
            <br />
                <div class="article_devider"> </div>
            <br />
        </li>
    </ItemTemplate>

    so in essence I want the hyperlink control to behaves like a hyperlink control that it can have NavigateURL is set to the URL and I can change the text to say "Please click here for more info".

    the hyperlink control is replacing the string, and if I click on the link, Im getting a Http Eror 404.0

    Thanks for the Help!
    Manny S.

     



  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Jan 2011
    Link to this post
    Hello Emmanuel,

    The problem is in the way that you set NavigateUrl of the HyperLink.

    <asp:HyperLink ID="Article_URL" runat="server" NavigateUrl="<%=this.Text%>">
                    <asp:Label ID="Article_Title" runat="server" CssClass="article_title" Width="360px"></asp:Label>
                </asp:HyperLink>
     


    One of the options here is creating a custom class that inherits from your ContentView based control. There you can override SetItemContent. From the itemContainer you can find your HyperLink and from the contentItem parameter you can extract the metakey you are looking for.

    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
  5. Emmanuel
    Emmanuel avatar
    5 posts
    Registered:
    13 Oct 2010
    24 Jan 2011
    Link to this post
    Ivan, 

    Thanks for the reply.  I tried to put into code what you said, I kinda got lost between itemContainer and the contentitem.  Could you provide a code example of what your talking about.  Thanks again!


  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Jan 2011
    Link to this post
    Hi Emmanuel,

    Here is a sample code

    protected override void SetItemContent(System.Web.UI.Control itemContainer, IContent contentItem)
    {
        var c1 = itemContainer.FindControl("SomeId") as HyperLink;
        base.SetItemContent(itemContainer, contentItem);
    }


    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
    Answered
  7. Emmanuel
    Emmanuel avatar
    5 posts
    Registered:
    13 Oct 2010
    25 Jan 2011
    Link to this post
    Super, I figured out the rest!  It works now.

    Thanks, bunch
Register for webinar
7 posts, 1 answered