Wednesday, March 28, 2012

ajax based page need to go to the top of the page....

Hi everyone ,,,

i have a page that contain update panel , that uses partial rendering ..

i need to go to the top of the page after postBack ... how do i do this ?

thnx ..


Why would you want a postback if you are using Update PanelSmile

The Update Panel and other partial rendering sections are solely meant for avoiding the page from going to the top for each and every action and retainng the scroll position.

Is there a specific reason you want the page to scroll up?


i need it because i have a gridview at the bottom of the page that i select a row from it ,

and i get an information about the row at the top of the page , if i have a lot of rows when i select a row i stay on the position of the row and the info is not display for

the user, the user need to scroll to the top of the page ..



Use this Peace of Code:
-------------------------------
<!--Add the following after the scriptmanager on your page:-->

 <script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
window.scrollTo(0,0);
}
</script>

--------------------------------

If that doesnt work for some reason, try this

Use HTML Bookmarks to achieve this without a Postback

1) Place HTML Bookmark <a name="top" >TOP</a> on Top of the Page

2) Use Response.Redirect("PageURL#top) to go to the top of the page

Read more about Bookmark on this:
http://www.freewebmasterhelp.com/tutorials/html-basics/4

Shrinand Vyas

No comments:

Post a Comment