?
Solved

When page loads, How can I go to the bottom of the page?

Posted on 2004-10-27
6
Medium Priority
?
1,507 Views
Last Modified: 2011-10-03
Every time I do a postback my page goes back to the top of the page.  My users have to keep scrolling down.  I have turned on Smart Navagation on my page but that has no effect.  Not sure why either.  My form pulls in alot of user controls.  On each post back it adds another user control to the bottom of the web form.  Thats the control I would want to have focus for lack of a better name.

Anyone got a suggestion on either how to set focus to a paticular User Control or how to make the page go to the bottom when it loads?

Thanks for your time!!!
0
Comment
Question by:accmats
6 Comments
 

Expert Comment

by:onura
ID: 12422261
Hi,

Put an anchor to the bottom of your page,
<a name="bottom">
and call your page with #bottom at the end.
During the postbacks it should go to bottom anchor.

This might work.
0
 

Author Comment

by:accmats
ID: 12422421
what would be the syntax of that #Bottom and would I put that in the page load event?
0
 

Expert Comment

by:onura
ID: 12422488
no, just put after the adress on the link like http://www.nowhere.com/page.aspx#start1
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 35

Expert Comment

by:YZlat
ID: 12422812
just use this javascript function:

function scrollToCoordinates() {
      window.scrollTo(0,800)
      
}

call it from body onLoad :

<body onload="javascript:scrollToCoordinates()" MS_POSITIONING="FlowLayout">
0
 
LVL 33

Expert Comment

by:raterus
ID: 12422813
nooo, don't use anchors!  You get the double-click effect when the page loads.  Use Javascript and the ScrollIntoView() function.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/scrollintoview.asp
0
 
LVL 35

Accepted Solution

by:
YZlat earned 1000 total points
ID: 12422854
add two hidden fields to the page, call then scrollx and scrolly. Then add the following javascript code:

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else {  // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}  
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}  
document.Form1.scrollx.value = tempX;
document.Form1.scrolly.value = tempY;

return true;
}
function scrollToCoordinates() {
      //alert(document.Form1.scrollx.value);
      //alert(document.Form1.scrolly.value);
      window.scrollTo(document.Form1.scrollx.value-50,document.Form1.scrolly.value-50)
      
}

Then call scrollToCoordinates from body onLoad:

<body onload="javascript:scrollToCoordinates()" MS_POSITIONING="FlowLayout">
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…

588 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