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

multiple comboboxes problems

1 Answer 67 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
matt
Top achievements
Rank 1
matt asked on 31 Oct 2008, 08:17 PM
hello,

ive seen this example for multiple comboboxes that interact w/ each other:

http://demos.telerik.com/ASPNET/Prometheus/Combobox/Examples/Functionality/MultipleComboBoxes/DefaultCS.aspx

and now im trying to get its technique to work w/ my own comboboxes. i am able to do so in  a naked .ASPX page. it works as expected, cool.

but when using MasterPages, im having a problem w/ this line:

var rcbVehicleModels = $find("rcbVehicleModels"); 

...this comes back NULL, and breaks the rest of the technique.

is there something i have to do differently when working w/ MasterPages? perhaps as in a parent element ID to to the $find() method?

thanks!
matt


my .ASPX code:

<asp:Content ID="Content1" ContentPlaceHolderID="phContent" runat="server"
 
    <table width="100%"
        <tr> 
            <td width="50%"
                <span class="formLabel">Make:</span><br /> 
                 
                <Telerik:RadComboBox ID="rcbVehicleMakes"  
                    DataValueField="VehicleMakeTypeID"  
                    DataTextField="Description"  
                    Width="150"  
                    DropDownWidth="220"  
                    AllowCustomText="False"  
                    MarkFirstMatch="true"  
                    Skin="Gray"  
                    OnClientSelectedIndexChanging="LoadModels"  
                    runat="server"/> 
                     
            </td> 
            <td width="50%"
                <span class="formLabel">Model:</span><br /> 
                 
                <Telerik:RadComboBox ID="rcbVehicleModels"  
                    DataValueField="VehicleModelTypeID"  
                    DataTextField="Description"  
                    Width="80"  
                    DropDownWidth="125"  
                    AllowCustomText="False"  
                    MarkFirstMatch="true"  
                    Skin="Gray"  
                    OnItemsRequested="rcbVehicleModels_ItemsRequested" 
                    OnClientItemsRequested="ItemsLoaded"  
                    runat="server" /> 
                     
            </td> 
        </tr> 
    </table> 
             
             
             
    <script type="text/javascript"
        //called when VehicleMakes changes 
        function LoadModels(combo, eventargs) 
        { 
            var item = eventargs.get_item(); 
 
            if (item.get_index() > 0) //Make selected, get Models 
            { 
                var rcbVehicleModels = $find("rcbVehicleModels"); 
 
                //alert(rcbVehicleModels); //returns NULL! 
 
                rcbVehicleModels.set_text("Loading..."); 
             
                rcbVehicleModels.requestItems(item.get_value(), false);                                 
            } 
            else //empty item selected, reset Models 
            { 
                rcbVehicleModels.set_text(" "); 
                rcbVehicleModels.clearItems(); 
            } 
        } 
         
        //called when VehicleModels loads its items  
        function ItemsLoaded(combo, eventarqs) 
        { 
            if (combo.get_items().get_count() > 0) 
            { 
                combo.set_text(combo.get_items().getItem(0).get_text()); 
                combo.get_items().getItem(0).highlight(); 
            } 
             
            combo.showDropDown(); 
        } 
    </script> 
 
</asp:Content> 
 




1 Answer, 1 is accepted

Sort by
0
matt
Top achievements
Rank 1
answered on 31 Oct 2008, 08:44 PM
got it -- when in a naked .ASPX page, the html clientside ID of the RadComboBox is the same as the server-side ID. but when in a content page, its prefixed w/ other junk, so you have to retrieve its clientside ID like so:

var rcbVehicleModels = $find('<%= rcbVehicleModels.ClientID %>'); 

Tags
ComboBox
Asked by
matt
Top achievements
Rank 1
Answers by
matt
Top achievements
Rank 1
Share this question
or