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

[Solved] Multiple ComboBoxes in User Control

2 Answers 164 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tommy Martin
Top achievements
Rank 1
Tommy Martin asked on 24 Jun 2008, 03:36 PM

I am creating a user control that I am trying to use the Multiple Combobox with the ClientSide OnClientSelectedIndexChanging event.  When I use the control, something doesn't appear to be working write.  If I use the code a web form the javascript works fine.  Here is what I have...

var deptCombo = $find("cboDepartment");

var item = eventArgs.get_item();

alert(item.get_text());

deptCombo.set_text(

"Loading...");


Thanks in advance for your help.

Tommy

2 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 25 Jun 2008, 07:23 AM
Hi Tommy Martin,

Welcome to Telerik Community!

You need to optain the reference to the combobox in the following way:

var deptCombo = $find("<%= cboDepartment.ClientID %>");

This will guarantee that the proper ID is passed to the find() method.

More information is avalable here:

I hope this helps.

All the best,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Simon Kingaby
Top achievements
Rank 2
answered on 25 Jun 2008, 08:41 PM
Also, depending how deep you are, you may not have access to the ("<%= cboDepartment.ClientID %>) function because the renamed control has been renamed again.  For example, if you put your RadComboBox inside a WebControl inside an ItemTemplate, the ClientID is lost in the final web page.

In this case, use a function like this to iterate through the Telerik.Web.UI.RadComboBox.ComboBoxes collection. This collection is populated by Telerik whenever a RadComboBox is added to a page.




function

GetGridCombo(id)

{

    if(Telerik.Web.UI.RadComboBox.ComboBoxes != null)

    {

        for(var i=0; i<Telerik.Web.UI.RadComboBox.ComboBoxes.length; i++)

        {

            var cbo = Telerik.Web.UI.RadComboBox.ComboBoxes[i];

            if(cbo._uniqueId.indexOf(id)>0)

            {

                return cbo;

            }

        }

    }

    return null;

}

Tags
ComboBox
Asked by
Tommy Martin
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Simon Kingaby
Top achievements
Rank 2
Share this question
or