473,756 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox vertical scroll position capture

Lit
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.

I want it to be remain in the Proximity of where it was before.

Can I capture the vertical scroll bar position of a ListBox in JavaScript
and set it?

Thank you,

Lit
Aug 21 '07 #1
7 5617
I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_Select edIndexChanged( ByVal sender As Object,
ByVal e As System.EventArg s) Handles ListBox1.Select edIndexChanged
Dim x As Integer = ListBox1.Select edIndex
ListBox1.Items. Remove(ListBox1 .SelectedItem)
ListBox1.Select edIndex = x + 1
End Sub
Steve C.
MCAD,MCSE,MCP+I ,CNE,CNA,CCNA
Lit wrote:
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.

I want it to be remain in the Proximity of where it was before.

Can I capture the vertical scroll bar position of a ListBox in JavaScript
and set it?

Thank you,

Lit

Aug 21 '07 #2
Lit
Steve,

Here is the problem:

After post back I don't want the selected Index set because I can no longer
select that Item by just clicking on it to cause a post back
I have an onSelectedIndex Changed event that fires when a list item is
selected.

How do I scroll as if I am a user scrolling without selecting anything.

( x below can be index out of bounds if last or listbox is empty )

Any JavaScript tricks, any other Ideas you can think off.

Thank you,
Lit

"Steve" <ln************ ********@gmail. comwrote in message
news:es******** ******@TK2MSFTN GP03.phx.gbl...
>I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_Select edIndexChanged( ByVal sender As Object, ByVal
e As System.EventArg s) Handles ListBox1.Select edIndexChanged
Dim x As Integer = ListBox1.Select edIndex
ListBox1.Items. Remove(ListBox1 .SelectedItem)
ListBox1.Select edIndex = x + 1
End Sub
Steve C.
MCAD,MCSE,MCP+I ,CNE,CNA,CCNA
Lit wrote:
>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.

I want it to be remain in the Proximity of where it was before.

Can I capture the vertical scroll bar position of a ListBox in JavaScript
and set it?

Thank you,

Lit
Aug 21 '07 #3
I understand. You're removing the item at index "x", so you can't select
it anymore. If you set the SelectedIndex to x+1 (or even x-1), that will
cause the item after (or before) to be the currently selected item. The
auto-postback still works, the item is still deleted, and the listbox
scroll position is still preserved.

You can try to capture that via Javascript, but in this case, it's not
needed, and just adds to the complexity. Besides, if you're using a
postback, you're already making the round-trip to the server, so you
might as well do everything there, right?

Steve C.
MCAD,MCSE,MCP+I ,CNE,CNA,CCNA
Lit wrote:
Steve,

Here is the problem:

After post back I don't want the selected Index set because I can no longer
select that Item by just clicking on it to cause a post back
I have an onSelectedIndex Changed event that fires when a list item is
selected.

How do I scroll as if I am a user scrolling without selecting anything.

( x below can be index out of bounds if last or listbox is empty )

Any JavaScript tricks, any other Ideas you can think off.

Thank you,
Lit

"Steve" <ln************ ********@gmail. comwrote in message
news:es******** ******@TK2MSFTN GP03.phx.gbl...
>I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_Select edIndexChanged( ByVal sender As Object, ByVal
e As System.EventArg s) Handles ListBox1.Select edIndexChanged
Dim x As Integer = ListBox1.Select edIndex
ListBox1.Items. Remove(ListBox1 .SelectedItem)
ListBox1.Select edIndex = x + 1
End Sub
Steve C.
MCAD,MCSE,MCP+ I,CNE,CNA,CCNA
Lit wrote:
>>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.

I want it to be remain in the Proximity of where it was before.

Can I capture the vertical scroll bar position of a ListBox in JavaScript
and set it?

Thank you,

Lit
Aug 21 '07 #4
Lit
Hi Steve,

I am using AJAX so my post back is not the ALL-Page Postback.
I select from the "Source" list box, add the item to a "Destinatio n" list
box and remove the item that was selected from the "Source" listbox.
Now if I ( x+1, or x-1 ) I can NO longer select that selected item to
trigger a postback, remember I am not clicking on a button.
The selected index change event does not fire when something is already been
selected.

Also if I change to x+1 or x-1 the event is fired on the server side, I
think so I have to disable the event before x+1 or x-1 then enable it
again.

How can I capture the list box vertical scroll position in JavaScript and
set it without selecting anything in the listbox
Is this doable for a listbox?

Does <Select Selected Fire An event, if not that is good. if yes that
is not the behavior I want.

Thanks for taking the time to thing this with me.

Lit

"Steve" <ln************ ********@gmail. comwrote in message
news:ue******** ******@TK2MSFTN GP04.phx.gbl...
>I understand. You're removing the item at index "x", so you can't select it
anymore. If you set the SelectedIndex to x+1 (or even x-1), that will cause
the item after (or before) to be the currently selected item. The
auto-postback still works, the item is still deleted, and the listbox
scroll position is still preserved.

You can try to capture that via Javascript, but in this case, it's not
needed, and just adds to the complexity. Besides, if you're using a
postback, you're already making the round-trip to the server, so you might
as well do everything there, right?

Steve C.
MCAD,MCSE,MCP+I ,CNE,CNA,CCNA
Lit wrote:
>Steve,

Here is the problem:

After post back I don't want the selected Index set because I can no
longer select that Item by just clicking on it to cause a post back
I have an onSelectedIndex Changed event that fires when a list item is
selected.

How do I scroll as if I am a user scrolling without selecting anything.

( x below can be index out of bounds if last or listbox is empty )

Any JavaScript tricks, any other Ideas you can think off.

Thank you,
Lit

"Steve" <ln************ ********@gmail. comwrote in message
news:es******* *******@TK2MSFT NGP03.phx.gbl.. .
>>I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_Select edIndexChanged( ByVal sender As Object,
ByVal e As System.EventArg s) Handles ListBox1.Select edIndexChanged
Dim x As Integer = ListBox1.Select edIndex
ListBox1.Items. Remove(ListBox1 .SelectedItem)
ListBox1.Select edIndex = x + 1
End Sub
Steve C.
MCAD,MCSE,MCP +I,CNE,CNA,CCNA
Lit wrote:
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.

I want it to be remain in the Proximity of where it was before.

Can I capture the vertical scroll bar position of a ListBox in
JavaScript and set it?

Thank you,

Lit

Aug 21 '07 #5
Ahhh, AJAX. Okay, so you've got to preserve the scroll location without
re-selecting any item in the listbox. I don't think I've ever seen any
Javascript that can do that, but I'm not a Javascript guru.

Try reposting this in the MS JScript newsgroups. I know JScript isn't
*exactly* javascript, but I don't think MS has an ASP.NET Ajax newsgroup
yet.


Lit wrote:
Hi Steve,

I am using AJAX so my post back is not the ALL-Page Postback.
I select from the "Source" list box, add the item to a "Destinatio n" list
box and remove the item that was selected from the "Source" listbox.
Now if I ( x+1, or x-1 ) I can NO longer select that selected item to
trigger a postback, remember I am not clicking on a button.
The selected index change event does not fire when something is already been
selected.

Also if I change to x+1 or x-1 the event is fired on the server side, I
think so I have to disable the event before x+1 or x-1 then enable it
again.

How can I capture the list box vertical scroll position in JavaScript and
set it without selecting anything in the listbox
Is this doable for a listbox?

Does <Select Selected Fire An event, if not that is good. if yes that
is not the behavior I want.

Thanks for taking the time to thing this with me.

Lit

"Steve" <ln************ ********@gmail. comwrote in message
news:ue******** ******@TK2MSFTN GP04.phx.gbl...
>I understand. You're removing the item at index "x", so you can't select it
anymore. If you set the SelectedIndex to x+1 (or even x-1), that will cause
the item after (or before) to be the currently selected item. The
auto-postback still works, the item is still deleted, and the listbox
scroll position is still preserved.

You can try to capture that via Javascript, but in this case, it's not
needed, and just adds to the complexity. Besides, if you're using a
postback, you're already making the round-trip to the server, so you might
as well do everything there, right?

Steve C.
MCAD,MCSE,MCP+ I,CNE,CNA,CCNA
Lit wrote:
>>Steve,

Here is the problem:

After post back I don't want the selected Index set because I can no
longer select that Item by just clicking on it to cause a post back
I have an onSelectedIndex Changed event that fires when a list item is
selected.

How do I scroll as if I am a user scrolling without selecting anything.

( x below can be index out of bounds if last or listbox is empty )

Any JavaScript tricks, any other Ideas you can think off.

Thank you,
Lit

"Steve" <ln************ ********@gmail. comwrote in message
news:es****** ********@TK2MSF TNGP03.phx.gbl. ..
I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_Select edIndexChanged( ByVal sender As Object,
ByVal e As System.EventArg s) Handles ListBox1.Select edIndexChanged
Dim x As Integer = ListBox1.Select edIndex
ListBox1.Items. Remove(ListBox1 .SelectedItem)
ListBox1.Select edIndex = x + 1
End Sub
Steve C.
MCAD,MCSE,MC P+I,CNE,CNA,CCN A
Lit wrote:
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.
>
I want it to be remain in the Proximity of where it was before.
>
Can I capture the vertical scroll bar position of a ListBox in
JavaScrip t and set it?
>
Thank you,
>
Lit
>

Aug 21 '07 #6
Lit
Steve,

thank you for your input, I will have to research this or come up with
other UI

Lit
"Steve" <ln************ ********@gmail. comwrote in message
news:eZ******** ******@TK2MSFTN GP03.phx.gbl...
Ahhh, AJAX. Okay, so you've got to preserve the scroll location without
re-selecting any item in the listbox. I don't think I've ever seen any
Javascript that can do that, but I'm not a Javascript guru.

Try reposting this in the MS JScript newsgroups. I know JScript isn't
*exactly* javascript, but I don't think MS has an ASP.NET Ajax newsgroup
yet.


Lit wrote:
>Hi Steve,

I am using AJAX so my post back is not the ALL-Page Postback.
I select from the "Source" list box, add the item to a "Destinatio n"
list box and remove the item that was selected from the "Source" listbox.
Now if I ( x+1, or x-1 ) I can NO longer select that selected item to
trigger a postback, remember I am not clicking on a button.
The selected index change event does not fire when something is already
been selected.

Also if I change to x+1 or x-1 the event is fired on the server side, I
think so I have to disable the event before x+1 or x-1 then enable it
again.

How can I capture the list box vertical scroll position in JavaScript and
set it without selecting anything in the listbox
Is this doable for a listbox?

Does <Select Selected Fire An event, if not that is good. if yes
that is not the behavior I want.

Thanks for taking the time to thing this with me.

Lit

"Steve" <ln************ ********@gmail. comwrote in message
news:ue******* *******@TK2MSFT NGP04.phx.gbl.. .
>>I understand. You're removing the item at index "x", so you can't select
it anymore. If you set the SelectedIndex to x+1 (or even x-1), that will
cause the item after (or before) to be the currently selected item. The
auto-postback still works, the item is still deleted, and the listbox
scroll position is still preserved.

You can try to capture that via Javascript, but in this case, it's not
needed, and just adds to the complexity. Besides, if you're using a
postback, you're already making the round-trip to the server, so you
might as well do everything there, right?

Steve C.
MCAD,MCSE,MCP +I,CNE,CNA,CCNA
Lit wrote:
Steve,

Here is the problem:

After post back I don't want the selected Index set because I can no
longer select that Item by just clicking on it to cause a post back
I have an onSelectedIndex Changed event that fires when a list item is
selected.

How do I scroll as if I am a user scrolling without selecting anything.

( x below can be index out of bounds if last or listbox is empty )

Any JavaScript tricks, any other Ideas you can think off.

Thank you,
Lit

"Steve" <ln************ ********@gmail. comwrote in message
news:es***** *********@TK2MS FTNGP03.phx.gbl ...
I reproduced what you're getting, and fixed it using this code:
>
>
Protected Sub ListBox1_Select edIndexChanged( ByVal sender As Object,
ByVal e As System.EventArg s) Handles ListBox1.Select edIndexChanged
Dim x As Integer = ListBox1.Select edIndex
ListBox1.Items. Remove(ListBox1 .SelectedItem)
ListBox1.Select edIndex = x + 1
End Sub
>
>
Steve C.
MCAD,MCSE,M CP+I,CNE,CNA,CC NA
>
>
Lit wrote:
>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.
>>
>I want it to be remain in the Proximity of where it was before.
>>
>Can I capture the vertical scroll bar position of a ListBox in
>JavaScri pt and set it?
>>
>Thank you,
>>
>Lit
>>
Aug 21 '07 #7
Lit
looking for good JavaScript website, groups out here???? that might help in
this problem?

Thank you,

Lit
"Lit" <sq**********@h otmail.comwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
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.

I want it to be remain in the Proximity of where it was before.

Can I capture the vertical scroll bar position of a ListBox in JavaScript
and set it?

Thank you,

Lit


Aug 21 '07 #8

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

Similar topics

0
1389
by: David Pratt | last post by:
Hi. I am putting together a database application on Zope. I have built a pager for my records (20 per page) but do not want the browser scroll bars to reset to the top of the browser each time the pager is advanced to the previous or next page. The normal behavior is fine for everything but the anchor tags I am using for the pager. Instead of resetting when a new page is sellected, I want the vertical scrollbar to maintain its ...
1
6880
by: Keltus | last post by:
Hello, I have a Form with a ListBox in it. I'd like to be able to scroll the ListBox even when it's not in focus. ie. when i scroll the mousewheel when my focus is on the form, I'd like the ListBox to scroll. Now, there are two ways I would think would work. The first is if I can resend the MouseEventArgs to the ListBox but there does not seen to be a way to pass that event along. The second is if I could manually scroll the ListBox...
1
6084
by: Ray Mitchell | last post by:
Hello, I have a simple application in which I am using a ListBox to display text strings for logging purposes. When the text area becomes full the new lines are added to the end and the vertical scroll bar becomes visible, however, it does not automatically scroll up to show the most recent lines. What do I need to do to get it to scroll all the way up each time a new line is added, even though I might have previously manually pulled...
4
8136
by: Sharon | last post by:
I have a ListBox on my form and wand to do auto scrolling, I can do that by: myListBox.ClearSelected(); OutputListBox.SelectedIndex = myListBox.Items.Count - 1; But it causes to unselect all selected items, so I wish do that by moving the vertical scroll bar, imbedded in the ListBox. But I couldn’t find a way to get the ListBox vertical scroll bar. Can anybody show how to obtain it and how to make move/scroll?? --
1
9868
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't work. Thanks ahead.
0
1758
by: billy_cormic | last post by:
Hello, I am currently using Visual Studio 2005 for a project and I am attempting to employing the new treeview control using VB.net. I have placed the treeview on top of a panel and have enabled vertical scrolling on the panel. The problem is that when I scroll down towards the bottom of the treeview and click on one of the nodes the scroll bar jumps back to the top. Is there anyway to keep the vertical scroll bar in the same position...
3
14464
by: superjacent | last post by:
Hope someone can help. I have a listbox displaying time periods in blocks of 15 mins for a 24 hour period, all up 96 rows. The listbox can only visibly show 20 rows a time. The default feature is that the first row is at the top of the listbox.
1
2951
by: orofiamma | last post by:
It may appear odd, but I need to control the vertical scrollbar position of a listbox by buttons. So I'll have a "Scroll up" button and a "Scroll down" button. When I click "Scroll down", i.e., the listbox must scroll down as if I clicked the bottom arrow of the scrollbar. Is it possible? Or is something impossible in c#? :) Thanks.
5
17763
by: WRH | last post by:
Hello I want to have a multicolumn listbox. I never used one before so I looked at a Help example. I set the multicolumn property and the column width and tested with this example... this.listBox3.Items.AddRange(new object { "Item 1, column 1", "Item 2, column 1", "Item 3, column 1",
0
9456
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
10034
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
9872
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...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8713
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...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.