Monday, March 30, 2009

How to move vertical scroll bar using javascript in ASP.Net Web Form

Whenever ASP.NET Web Form page loaded, by defualt its focus set to first control (vertical scroll bar moved downward in this case) in the ASP.Net web form page. If you required to move your vertical scroll bar to the top of the page, then following client-side script help you in achieving this task:

<script>
function moveVerticalScroll()
{
document.body.scrollTop=0;
}
window.onload=
moveVerticalScroll;

</script>




Share:

1 comments:

Neal Holtschulte said...

FYI: this works when the script and function are in the head, but do NOT work when they're in the body.

About Me

My photo
Based in Bangalore, INDIA, Amit is a MCC. He has an MCA from the U.P.T.U., INDIA and holds Microsoft certifications including SharePoint 2007/2010/2013. He is an contributor to MSDN and http://amitkumarmca04.blogspot.com/. Amit have experience in SharePoint,ASP.Net with C#, Classic ASP, VB,Macros,HTML,JavaScript,JSON,BootStrap and AngularJS.

Followers

Labels