Bookmark NavigateURL in a custom control RRS feed

  • Question

  • User-1874149369 posted

    I just converted some code in a .aspx page to a control (.ascx).  Within this page, I have hyperlinks to bookmarks on the same page - these got moved to the control.  However, now the bookmark doesn't work.  How do you define/assign the NavigateURL property of a hyperlink to be a bookmark, within a custom control?

    Here is the hyperlink control
     <asp:HyperLink ID="lnkStep1" TabIndex="1" CssClass="nowrap" runat="server" NavigateUrl="#Step1">Step1</asp:HyperLink>

    Target is
    <td class="stepImageCell">
          <a id="Step1"></a>
          <asp:Image ID="Icon1" runat="server" AlternateText="Step 1" ImageUrl="../Images/1_icon.gif" />
    </td><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
    Tuesday, July 22, 2008 12:04 PM


All replies

  • User481221548 posted

    Hi Paul

    What means "doesnt work"?
    I would say: Make using of the root-operator, supported by ASP.NET.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 22, 2008 8:15 PM
  • User-1874149369 posted

    Thanks Peter.  What I meant by doesn't work is that I would get an exception, couldn't find the target.  The default directory was the Controls subfolder, and I was having trouble getting back to the source page.

     I tried hardcoding that page in the NavigateURL property in the .ascx file but the best that did was to land me on the page, but all my styles, etc., were lost.

    I then poked around at the link you sent, and got Request.Path to work.  I now build and assign the NavigateURL value in the control code behind, and after a few misses got that to work perfectly.  Thank you!!!


    P.S., code behind below

    this.lnkStep1.NavigateUrl = Request.Path.ToString() + "#Step1";

    Wednesday, July 23, 2008 11:11 AM