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

Forums / Bugs & Issues / How to use named anchors on page without using Lists

How to use named anchors on page without using Lists

4 posts, 0 answered
  1. Elmi
    Elmi avatar
    3 posts
    Registered:
    19 May 2008
    19 Sep 2008
    Link to this post
    I have some pages for which I want to add links to the top of the page that will go to named anchors further down on the same page. It looks very similar to the Anchor List but I use a lot of other modules (like images etc.) on the page, so the List module will not work.

    I have added the named anchors to the Generic Content (e.g. <a name="screenshots" id="screenshots"></a><h3>Screenshots</h3>) and added Hyperlink controls with the needed links (e.g. ~Products/ClientOne.aspx#screenshots) But when the page is published, the links change to mySite/App_Master/#screenshots.

    How can I reference a named anchor on a page?
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    20 Sep 2008
    Link to this post
    Hi Elmi,

    here is the line of code that performs the desired functionality for the anchor list:

    listTitle.HRef = this.Page.Request.RawUrl + "#" + ((INamedList)e.Item.DataItem).ID.ToString(); 

    Obviously, you would need to replace the part after "#" with the actual id of the element to which link should navigate.

    I hope you'll find this information helpful. Let us know if there is anything else we can do for you.

    Sincerely yours,
    Ivan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Jay Mehta
    Jay Mehta avatar
    28 posts
    Registered:
    30 Jun 2009
    03 Aug 2009
    Link to this post
    Hi Ivan,

    Could you please elaborate your answer, where exactly I use the line of code you described?

    Thank you,
    Jay Mehta.
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    06 Aug 2009
    Link to this post
    Hi Jay Mehta,

    This is done in the ListDisplay code behind file, in order to change the links produced by the Links module. You can create a code behind or override the existing ListDisplay. In this particular code, we are caching the databind event (e.Item.DataItem)and change every link.

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
Register for webinar
4 posts, 0 answered