Scroll to top when update inside update panel

I have a repeater that is placed inside an update panel.
When I click at one of the buttons inside this I want the page to be scrolled to the top.

I have googled a solution: (see code)

The problem with this solution is that it respond to all updates. I want it to execute just when the user clicks a specific button..

somebody knows a easy solution?
<script type="text/javascript" language="javascript">
  function EndRequestHandler(sender, args)

Open in new window

Who is Participating?
prairiedogConnect With a Mentor Commented:
You are almost there. Here is what you need:
Change "ctl00_C1_JobsGridView" in the article to your button's generated ID found in page source.
Praveen VenuTechnical Project ManagerCommented:
simple.. In the button1_click after all other code execute


jimmieanderssonAuthor Commented:
thanks, I changed your script a little to:

ScriptManager.RegisterClientScriptBlock(uplShoppingCart, this.GetType(), "scrToTop", "<script>scrollTo(0,0);</script>", false);

what happens now is that the page first scroll to the top but only stays until the page is fully loaded again (<1 sec). It then goes back to the original scroll position.
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Praveen VenuTechnical Project ManagerCommented:
check to see if your URL has any #


System.Web.UI.Page.MaintainScrollPositionOnPostBack = false;
ScriptManager.RegisterClientScriptBlock(uplShoppingCart, this.GetType(), "scrToTop", "<script>scrollTo(0,0);</script>", false);

jimmieanderssonAuthor Commented:
sorry, no # in URL

this.Page.MaintainScrollPositionOnPostBack = false;
gave the same result.

I also tried setting MaintainScrollPositionOnPostBack  in the aspx @page directive but no difference
I have the same issue.  It's as tho the postback is telling the app to go back to the same position, no matter how I try to override.  I've tried it at the 'onValueChanged' of a hiddenfield.  (The page number) which seems reasonable, but always end up at the same spot.
jimmieanderssonAuthor Commented:
I havn't solved this yet so if you do, please let me know.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.