<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
          <telerik:radcombobox 
                  id="RadComboBox1" 
                  Runat="server"
                  Height="140px" 
                  Width="215px" 
                  ShowToggleImage="True"
                  Skin="WebBlue"
                  OnClientSelectedIndexChanging="LoadCountries" 
                  EnableLoadOnDemand="true"
                  OnClientLoad="clientLoad"
                  OnClientItemsRequested="itemsRequested">
                <WebServiceSettings Method="GetContinentsNames" Path="Continents.asmx" />
           </telerik:radcombobox>
           <br />
            <telerik:radcombobox
                    id="RadComboBox2" 
                    Runat="server" 
                    Height="140px" 
                    Width="215px" 
                    ShowToggleImage="True"
                    Skin="WebBlue"
                    EnableLoadOnDemand="true"
                    OnClientItemsRequested="ItemsLoaded" 
                    AllowCustomText="true">
               <WebServiceSettings Method="GetCuntriesNames" Path="Countries.asmx" />     
           </telerik:radcombobox>  
        </div> 
        <script type="text/javascript">

                function LoadCountries(combo, eventarqs)
                {    
                    var countriesCombo = $find("RadComboBox2");    
                    
                    var item = eventarqs.get_item();
                    countriesCombo.set_text("Loading...");        
                   countriesCombo.requestItems(item.get_value(), false);                                                       
                }
                
                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).select();
                        combo.get_items().getItem(0).highlight();
       
                    }
                   var item = combo.findItemByValue("2");
                   item.select();
                }
                
                function clientLoad(combo, args)
                {
                    combo.requestItems("", false);
                }
       
                function itemsRequested(combo, args)
                {
                   var item = combo.findItemByValue("1");
                   item.select();
                }
               
        </script>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </form>
</body>
</html>
