locked
how to call anchor tag in another page using c# .net RRS feed

  • Question

  • User1046245955 posted

    i have a page with anchor i need to call the page and the anchor. 

    here's my code:

    Contact.aspx (without anchor)

    <li class=""><a href="Default.aspx">Support</a></li> (If the user click this automatic will go to Default.aspx#support)
    <li class=""><a href="#">Contact</a></li>

    Monday, January 20, 2020 10:13 AM

All replies

  • User-1780421697 posted

    Please clarify:

    From Contact.aspx you want to redirect user to Default.aspx#support

    Monday, January 20, 2020 10:18 AM
  • User753101303 posted

    Hi,

    As you told the anchor is just appended to the page name ie : <a href="Default.aspx#support">Support</a> 

    Or be more explicit about the problem you seems to have with using anchors...

    Monday, January 20, 2020 10:26 AM
  • User1046245955 posted

    from my contact.aspx once the user click a menu it will be directed to Default.aspx#support (<li class=""><a href="Default.aspx">Support</a></li>  )

    Monday, January 20, 2020 10:43 AM
  • User-1780421697 posted

    In javascript function like

    function localRedirect()
    {
       window.location="/default.aspx#support";    //Or path like http://localhost/Default.aspx#support
    }

    <button onclick="localRedirect()"></button>

    <a onclick="localRedirect()" >Support</a></li>

    Monday, January 20, 2020 10:50 AM
  • User753101303 posted

    And so you tried the simplest solution which should be to just use :

    <a href="Default.aspx#support">Support</a> 

    and that's it... The browser will be directed to default.aspx and will put into view the place where you have you are <a name="support"> anchor... 

    Monday, January 20, 2020 10:54 AM
  • User283571144 posted

    Hi, paminchever,

    I understand that you want to write the markup like this, e.g. (<li class=""><a href="Default.aspx">Support</a></li> ), for every list item in menu and the page will be redirected to another page with anchor when user clicks the menu list.

    This can be achieved using jquery selector as I made code as below. In the code, I presumed that the menu list's structure is each anchor inside a list item. (<li><a href=""></a></li> )

    Script:

    <script>
                $().ready(function () {
                    $("li a").each(function () {
                        console.log(this);
                        this.href += "#" + this.innerText;
                        console.log(this.href);
                    })
                })
    </script>
    

    Best Regards,

    Brando

    Tuesday, January 21, 2020 9:57 AM