?
Solved

How do I scroll to the top of an ASP.NET page after postback?

Posted on 2008-11-04
2
Medium Priority
?
603 Views
Last Modified: 2012-05-05
Hi Experts,

I use this on top of my ASP.NET page to maintain the scroll position after postback.

<%@ Page Language="VB" MaintainScrollPositionOnPostback="true" %>

This comes in handy because I have a long form, with Listboxes that do Autopostabacks.  When I click the Submit button though, I want to page to scroll back to the top of the page, because any error messages are displayed on the top of the page.

How can I accomplish this?
0
Comment
Question by:crickpaolo
2 Comments
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 2000 total points
ID: 22879587
You can either use javascript
ClientScript.RegisterStartupScript(gettype(),"scroll(0,0)", true);

or disable MaintainScrollPositionOnPostback during submit click
Page.MaintainScrollPositionOnPostback = false
0
 

Author Closing Comment

by:crickpaolo
ID: 31513239
perfect! thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

864 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