473,769 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET ListBox, post back and focus of selected items

Hi,

Issue: After post back selected item of a list box is getting out of
focus (when it contains more items than it's size).

I have a List Box in an ASPX page. I select an item from the ListBox
and after post back the item is still selected but it is not focused
(i.e. I have to scroll down to see the selected item)

Any way to fix this!

Thanks.

May 14 '07 #1
6 16415
See if setting MaintainScrollP ositionOnPostba ck="true" for the @Page attibute
helps.

"probashi" wrote:
Hi,

Issue: After post back selected item of a list box is getting out of
focus (when it contains more items than it's size).

I have a List Box in an ASPX page. I select an item from the ListBox
and after post back the item is still selected but it is not focused
(i.e. I have to scroll down to see the selected item)

Any way to fix this!

Thanks.

May 15 '07 #2
Unfortunately it does not help.

Looks like custom JavaScript will be my last option.

Thanks

On May 15, 2:43 am, Siva M <shiva...@onlin e.excite.comwro te:
See if setting MaintainScrollP ositionOnPostba ck="true" for the @Page attibute
helps.

"probashi" wrote:
Hi,
Issue: After post back selected item of a list box is getting out of
focus (when it contains more items than it's size).
I have a List Box in an ASPX page. I select an item from the ListBox
and after post back the item is still selected but it is not focused
(i.e. I have to scroll down to see the selected item)
Any way to fix this!
Thanks.- Hide quoted text -

- Show quoted text -

May 15 '07 #3
probashi,

on page load event you could do something like the following to ensure the
selected item is visible:
<script type="text/javascript">
var lst = document.getEle mentById('<%= myListBox.Clien tID %>';
if (lst && lst.selectedInd ex -1){
lst.focus();
lst.selectedInd ex = lst.selectedInd ex;
}
</script>

Hope it is not too late for you

"probashi" wrote:
Unfortunately it does not help.

Looks like custom JavaScript will be my last option.

Thanks

On May 15, 2:43 am, Siva M <shiva...@onlin e.excite.comwro te:
See if setting MaintainScrollP ositionOnPostba ck="true" for the @Page attibute
helps.

"probashi" wrote:
Hi,
Issue: After post back selected item of a list box is getting out of
focus (when it contains more items than it's size).
I have a List Box in an ASPX page. I select an item from the ListBox
and after post back the item is still selected but it is not focused
(i.e. I have to scroll down to see the selected item)
Any way to fix this!
Thanks.- Hide quoted text -
- Show quoted text -


May 18 '07 #4
Looks like I cannot solve this with JavaScript either.

Here is the code I tried.
<script type= "text/javascript">
var lst = document.getEle mentById("list1 ");
var options = lst.options;
var option;
var i;
for(i = 0; i < options.length; i++)
{

if(options[i].selected)
{

options[i].focus();
}
}
</script>

On May 15, 9:27 am, probashi <proba...@hotma il.comwrote:
Unfortunately it does not help.

Looks like custom JavaScript will be my last option.

Thanks

On May 15, 2:43 am, Siva M <shiva...@onlin e.excite.comwro te:
See if setting MaintainScrollP ositionOnPostba ck="true" for the @Page attibute
helps.
"probashi" wrote:
Hi,
Issue: After post back selected item of a list box is getting out of
focus (when it contains more items than it's size).
I have a List Box in an ASPX page. I select an item from the ListBox
and after post back the item is still selected but it is not focused
(i.e. I have to scroll down to see the selected item)
Any way to fix this!
Thanks.- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

May 18 '07 #5
probashi,

take a look at my previous response - I have tested it before posting - it
does select the correct item on postback - you need to focus the list and
then select the selected item again.

"probashi" wrote:
Looks like I cannot solve this with JavaScript either.

Here is the code I tried.
<script type= "text/javascript">
var lst = document.getEle mentById("list1 ");
var options = lst.options;
var option;
var i;
for(i = 0; i < options.length; i++)
{

if(options[i].selected)
{

options[i].focus();
}
}
</script>

On May 15, 9:27 am, probashi <proba...@hotma il.comwrote:
Unfortunately it does not help.

Looks like custom JavaScript will be my last option.

Thanks

On May 15, 2:43 am, Siva M <shiva...@onlin e.excite.comwro te:
See if setting MaintainScrollP ositionOnPostba ck="true" for the @Page attibute
helps.
"probashi" wrote:
Hi,
Issue: After post back selected item of a list box is getting out of
focus (when it contains more items than it's size).
I have a List Box in an ASPX page. I select an item from the ListBox
and after post back the item is still selected but it is not focused
(i.e. I have to scroll down to see the selected item)
Any way to fix this!
Thanks.- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -


May 21 '07 #6
I am sorry for not describing the issue properly.

This issue exists only for multi-select list box.

The code you sent does not work for multi-select list box. It makes
the selected item visible but wipes out all the other selections.

Thanks.

On May 18, 12:59 am, Sergey Poberezovskiy
<SergeyPoberezo vs...@discussio ns.microsoft.co mwrote:
probashi,

on page load event you could do something like the following to ensure the
selected item is visible:
<script type="text/javascript">
var lst = document.getEle mentById('<%= myListBox.Clien tID %>';
if (lst && lst.selectedInd ex -1){
lst.focus();
lst.selectedInd ex = lst.selectedInd ex;}

</script>

Hope it is not too late for you

"probashi" wrote:
Unfortunately it does not help.
Looks like custom JavaScript will be my last option.
Thanks
On May 15, 2:43 am, Siva M <shiva...@onlin e.excite.comwro te:
See if setting MaintainScrollP ositionOnPostba ck="true" for the @Page attibute
helps.
"probashi" wrote:
Hi,
Issue: After post back selected item of a list box is getting out of
focus (when it contains more items than it's size).
I have a List Box in an ASPX page. I select an item from the ListBox
and after post back the item is still selected but it is not focused
(i.e. I have to scroll down to see the selected item)
Any way to fix this!
Thanks.- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

May 21 '07 #7

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

Similar topics

9
4045
by: Irene | last post by:
I'm developing a Web application where a user selects from a listbox which can have many items. The initial display only shows about 10 items. After a postback, the listbox is automatically scrolled back to the top, so the selected item is mostly no longer visible. How can I keep the position, so that the selected item is still shown?
9
45502
by: Alpha | last post by:
Hi, How can I set all the items in a listbox to be selected? I can't find a property or mehtod to do it so I thought I'll try using setselected method but I need to find out how many items are in the listbox. Thanks, Alpha
1
8421
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What I want to do is to allow the user to click on the row that corresponds to the correct address, and have the code behind populate the form's Address1, Address2 etc. controls with the relevant data items. I put the code for this into the...
6
2879
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset a denormalized mirror of the database, but I'm not having much luck getting the selection logic down (I haven't found a 'hook' where I can access the listbox object as an object to set the listitem's selected property before it gets rendered).. ...
10
3303
by: Adam Clauss | last post by:
I have a page containing a list box. This list may contain duplicate items - in which the ORDER is important. ex: a b b a is significant as compared to: b
2
3136
by: dan heskett | last post by:
I am owner-drawing a listbox, in an attempt to create a nice list with some custom "fields" and text layout. Essentially it works, but I must be missing something big, conceptually, because I get all kinds of screen artifacts and weirdness. My general goal is: list item with a few areas for text, every other item shaded a light color for readability, font color changes with selection. The listbox is populated with custom structurs...
9
3249
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback). This listbox has AutoPostback = True. When the user selects an item from this list, the second listbox is populated with more items relevant to this selection. I am using an SQLDataSource web control for this. These items are headers. I want, when...
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.
4
4634
by: bogdan | last post by:
Hi, I have two listboxes on a page and need to move items between them - using buttons (e.g. "<<" ">>"). Can this be done on a client side in asp.net? I'd like to avoid hitting the server on every add/remove. Thanks, Bogdan
0
10045
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
9994
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
8870
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
7408
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
6673
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
5298
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...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.