ASP.NET: Moving to a named anchor in VB.NET code

Posted on 2005-05-03
Last Modified: 2010-05-19
I have a web page that is displayed in an IFrame. At the bottom of the page is a Save command button the user clicks when they are done editing and they want to save their changes. It fires a sub of VB.NET code that saves the data in a SQL Server.

At the top of the page is a named anchor that looks like this:

<A NAME="Top"></A>

When the user clicks the Save button to save the data, I want to redirect the user to the named anchor at the top of the page so the page is scrolled back to the top of the IFrame. How do I do it?
Question by:rgrimm

    Author Comment

    I have found the answer to my own question.

    In the Page_Load section, you want to write code that adds the onclick attribute to the command button. It would look something like this:

    cmdSubmit.Attributes.Add("onclick", "javascript:form1.ControlName.focus();")


    form1    is the name of the form ( <FORM ID="form1" ... )
    ControlName    is the name of the control you want to go to when the button is clicked
    LVL 2

    Accepted Solution

    Closed, 500 points refunded.
    Friendly Neighbourhood Community Support Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now