473,769 Members | 6,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save scroll position AND setFocus

JC
I'm sure you've all seen the save scroll position from 4 guys from
rolla which can be found here >
http://aspnet.4guysfromrolla.com/articles/111704-1.aspx
BUT
try to get that to work AND still be able to set the focus to a
control.

Here's the problem, when you set the focus by using the
registerstartup script method the control gets the focus after the
scroll position has been set. When this happens the scroll position
gets set a second time but it sets the focused control at the bottom
of your page.
To test-
(you would need the scroll position code from the 4 guys site)
Build a page with a whole lot of <br>'s and in the middle put a
textbox and at the end put a button. In the button call

RegisterStartup Script("focus", "<script language=""Java Script"">" &
vbCrLf & vbTab & "document.getEl ementById('Text Box3').focus(); " &
vbCrLf & "<" & "/script>")

I want my page to stay scrolled to the bottom but it scrolls to the
point of the textbox.

Any ideas on how to fix this would be AMAZINGLY appreciated. I don't
need to use this code just need it to work.
No, smartnavigation will not work since you can not focus with that
either
(or if you can, let me know but I'd rather not use it)

contact me at the e-mail or at ujjc001@ on my gmail account but please
post here too for others to share.
Nov 19 '05 #1
1 8681
you need to set the focus after the scroll has happened. your focus scroll
changes the saved coordinates. there scroll happens at onload, and you need
to let the window scroll happen first. change their code to something like:

function sstchur_SmartSc roller_Scroll()
{
var x = document.forms[formID].xCoordHolder.v alue;
var y = document.forms[formID].yCoordHolder.v alue;
document.forms[formID].focusHolder.va lue;
window.scrollTo (x, y);

window.setTimeo ut("document.fo rms[document.forms[formID].focusHolder.va lue].
focus()",10);
}

where you store the focus field name in focusHolder
-- bruce (sqlwork.com)
"JC" <uj*****@charte r.net> wrote in message
news:b8******** *************** ***@posting.goo gle.com...
| I'm sure you've all seen the save scroll position from 4 guys from
| rolla which can be found here >
| http://aspnet.4guysfromrolla.com/articles/111704-1.aspx
| BUT
| try to get that to work AND still be able to set the focus to a
| control.
|
| Here's the problem, when you set the focus by using the
| registerstartup script method the control gets the focus after the
| scroll position has been set. When this happens the scroll position
| gets set a second time but it sets the focused control at the bottom
| of your page.
| To test-
| (you would need the scroll position code from the 4 guys site)
| Build a page with a whole lot of <br>'s and in the middle put a
| textbox and at the end put a button. In the button call
|
| RegisterStartup Script("focus", "<script language=""Java Script"">" &
| vbCrLf & vbTab & "document.getEl ementById('Text Box3').focus(); " &
| vbCrLf & "<" & "/script>")
|
| I want my page to stay scrolled to the bottom but it scrolls to the
| point of the textbox.
|
| Any ideas on how to fix this would be AMAZINGLY appreciated. I don't
| need to use this code just need it to work.
| No, smartnavigation will not work since you can not focus with that
| either
| (or if you can, let me know but I'd rather not use it)
|
| contact me at the e-mail or at ujjc001@ on my gmail account but please
| post here too for others to share.
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3709
by: Boniface Frederic | last post by:
Hello, I have frame displaying the last posted messages. I set <meta http-equiv="refresh" content="5"/> to automatically refresh the frame every 5s My problem is; if I scroll the frame to see messages up or down, after the refresh, the scroll position is reseted to the top of the frame and my scroll position is lost.
2
1810
by: GrantS | last post by:
I am trying to convert the VB.Net code example povided by http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx into C# (ASP.Net)without success. No errors are thrown in the VB code provided on the website. Once I have this example running correctly, I will need to use the concept in a more complex project. The code I am using involves an webform and an htc file. The code for ScrollPos.htc (which is located in a folder...
1
4952
by: Ted | last post by:
I am trying to return the vertical scroll position of a rich textbox control using Access 2000. It seems to work for the horizontal scroll bar, but not the vertical. Code follows: Option Explicit Private Declare Function GetScrollPos Lib "user32" (ByVal hwnd As Long, ByVal nBar As Long) As Long Private Declare Function GetFocus Lib "user32" () As Long Private Const SB_VERT = 0
4
5934
by: 2D Rick | last post by:
In Access2003 and XP. My forms detail section hides behind the header when I scroll down to see controls off screen. This is similar to freezing a pane in Excel. I'd rather this did not happen but can't find the property that controls this. When the form first opens some of the controls are behind the header and scrolling is required to see them. Help, thanks, RICK
0
2097
by: Keithb | last post by:
The maintain scroll position on postback feature works as expected with my site running under localhost on the development machine. When the files are posted to an IIS 6.0 web server running on a Win2k3 box, maintain scroll position on postback simply does not work. The Page_Load event handler in my aspx page has: Page.MaintainScrollPositionOnPostBack = true;
5
10182
by: RobertK | last post by:
I have a table that displays one row of images (thumbnails). When a user clicks on an image it opens up a bigger image below it. The row has about 20 cells. I have a <divtag which allows the user to scroll left and right to see all the images. The problem is that when the user scrolls to the middle and clicks on the image. The click causes a post back and the page loads again and the scroll bar goes to the left. I need to know how to...
7
5619
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client browser the list box scroll position is at the top.
1
3101
by: wmbrae | last post by:
I trying to make a javascript document reader in 2 frames. The left frame displays the document, the right frame shows a list of document links. This is as far as I got http://www.geocities.com/viewdoq/opening.htm (there are Firefox and Ie, and Ie version incompatiblities and clean-up which I will work on later) Does anybody have one ready made? I'd like to load the document and move the scroll position to where it was last viewed.
12
7880
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. There are a number of elements within this <div> that cause the <div> to participate in an Ajax call to the server. In order to maintain the scroll position of the <div> during the Ajax request I store the scroll value in a hidden field so that when...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.