jimmieandersson
asked on
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?
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">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{
scrollTo(0,0);
}
</script>
ASKER
thanks, I changed your script a little to:
ScriptManager.RegisterClie ntScriptBl ock(uplSho ppingCart, this.GetType(), "scrToTop", "<script>scrollTo(0,0);</s cript>", 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.
ScriptManager.RegisterClie
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.
check to see if your URL has any #
else
try
System.Web.UI.Page.Maintai nScrollPos itionOnPos tBack = false;
ScriptManager.RegisterClie ntScriptBl ock(uplSho ppingCart, this.GetType(), "scrToTop", "<script>scrollTo(0,0);</s cript>", false);
else
try
System.Web.UI.Page.Maintai
ScriptManager.RegisterClie
ASKER
sorry, no # in URL
this.Page.MaintainScrollPo sitionOnPo stBack = false;
gave the same result.
I also tried setting MaintainScrollPositionOnPo stBack in the aspx @page directive but no difference
this.Page.MaintainScrollPo
gave the same result.
I also tried setting MaintainScrollPositionOnPo
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.
ASKER
I havn't solved this yet so if you do, please let me know.
thanks
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Page.RegisterStartUpScript