This is a migrated thread and some comments may be shown as answers.

Scroll to the selecteditem in listbox

1 Answer 79 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 04 Aug 2011, 07:52 PM
I know there are a couple examples of this but none of them fit my exact situation and I need to solve this problem quickly.  Please help.

I have a page with a a radwindow that pops up.  Inside the radwindow are a few controls but the ones that come into play are an image button, a combobox and a listbox.  The combobox is filled with a list of many items that can be easily searched using the autofill feature.  The listbox has the same list of items.  Once the user finds the item he is looking for, the user clicks the image button and the list box is supposed to selects the same item and autoscroll to that item so the user can then select multiple items after the selected item.

I am able to do all of this except have the listbox autoscroll to the item and show it visibly in the list box.

The code I found that I think is close to what I need uses this javascript:

        Sys.Application.add_load(function (e) {
            var item = $find("lstAllGroups").get_selectedItem();
 
            if (item)
                item.scrollIntoView();

The problem I am having is the control called lstAllGroups can't be found and I don't know how to activate the javascript from the code behind.

If you would be able to supply a complete example of this, I would be grateful.

RJ

1 Answer, 1 is accepted

Sort by
0
Ivan Zhekov
Telerik team
answered on 05 Aug 2011, 01:32 PM
Hi Richard,

If the control can not be found, there are two reasons:

1) The id you tying to get is the short ClientID. In this case use "<%= somecontrol.ClientID %>" to get the actual ID.
2) If you are using static CliendID and in this case the control is not yet rendered on the page.

If the controls is not yet rendered, you may execute the javascript from code behind in some event after control initialization.
There are various posts on the web how to achieve this.

Best wishes,
Ivan Zhekov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ListBox
Asked by
Richard
Top achievements
Rank 1
Answers by
Ivan Zhekov
Telerik team
Share this question
or