473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 5561
I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim x As Integer = ListBox1.SelectedIndex
ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox1.SelectedIndex = 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 onSelectedIndexChanged 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**************@TK2MSFTNGP03.phx.gbl...
>I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim x As Integer = ListBox1.SelectedIndex
ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox1.SelectedIndex = 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 onSelectedIndexChanged 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**************@TK2MSFTNGP03.phx.gbl...
>I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim x As Integer = ListBox1.SelectedIndex
ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox1.SelectedIndex = 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 "Destination" 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**************@TK2MSFTNGP04.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 onSelectedIndexChanged 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**************@TK2MSFTNGP03.phx.gbl...
>>I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim x As Integer = ListBox1.SelectedIndex
ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox1.SelectedIndex = 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 "Destination" 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**************@TK2MSFTNGP04.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 onSelectedIndexChanged 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**************@TK2MSFTNGP03.phx.gbl...
I reproduced what you're getting, and fixed it using this code:
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim x As Integer = ListBox1.SelectedIndex
ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox1.SelectedIndex = 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 #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**************@TK2MSFTNGP03.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 "Destination"
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**************@TK2MSFTNGP04.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 onSelectedIndexChanged 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**************@TK2MSFTNGP03.phx.gbl...
I reproduced what you're getting, and fixed it using this code:
>
>
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim x As Integer = ListBox1.SelectedIndex
ListBox1.Items.Remove(ListBox1.SelectedItem)
ListBox1.SelectedIndex = 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 #7
Lit
looking for good JavaScript website, groups out here???? that might help in
this problem?

Thank you,

Lit
"Lit" <sq**********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.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
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...
1
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...
1
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...
4
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...
1
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...
0
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...
3
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...
1
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.,...
5
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... ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.