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

Posted on 2005-05-03
Medium Priority
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

ID: 14050697
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

Accepted Solution

Lunchy earned 0 total points
ID: 14056097
Closed, 500 points refunded.
Friendly Neighbourhood Community Support Admin

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

749 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