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

Web Service not called

2 Answers 168 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 2
Rick asked on 10 Feb 2009, 01:39 AM
I am trying to populate my RadComboBox from a web service. I have a simple example working in a separate project, but when I paste the same code into my project (same control, same web service), the web service is not called and the combo box is not populated.

What could I be doing that would prevent the web service from being called?

Rick.

In the form:  
 
<rad:RadComboBox ID="RadComboBox1"   
  EnableLoadOnDemand="true" 
  Skin="Vista" 
  runat="server">  
  <WebServiceSettings Path="../Controls/WebService.cs" Method="GetData" /> 
</rad:RadComboBox> 
 
WebService:  
 
<%@ WebService Language="C#" CodeBehind="~/App_Code/WebService.cs" Class="WebService" %> 
 
WebService CodeBehind:  
 
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.Services;  
using Telerik.Web.UI;  
 
/// <summary> 
/// Summary description for WebService  
/// </summary> 
[WebService(Namespace = "http://tempuri.org/")]  
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
[System.Web.Script.Services.ScriptService]  
public class WebService : System.Web.Services.WebService  
{  
 
    public WebService()  
    {  
    }  
 
    [WebMethod]  
    public RadComboBoxData GetData(RadComboBoxContext context)  
    {  
        RadComboBoxData result = new RadComboBoxData();  
 
        List<RadComboBoxItemData> items = new List<RadComboBoxItemData>();  
 
        for (int i = 0; i < 10; i++)  
        {  
            RadComboBoxItemData item = new RadComboBoxItemData();  
            item.Text = "Item " + i.ToString();  
            items.Add(item);  
        }  
 
        result.Items = items.ToArray();  
        return result;  
    }  
 
}  
 
 
 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Feb 2009, 04:35 AM
Hi Rick,

Set the path as WebService.asmx instead of WebService.cs and check whether its working fine. I tried the code below and its working fine for me.

Here is the ASPX:
<telerik:RadComboBox ID="RadComboBox2"  EnableLoadOnDemand="true"  Skin="Vista"    runat="server">    
  <WebServiceSettings Path="WebService.asmx" Method="GetData" />   
</telerik:RadComboBox>  

Thanks,
Shinu.

0
Rick
Top achievements
Rank 2
answered on 18 Feb 2009, 02:58 PM

Shinu,

   Yes, that was one problem.

   The other problem, in my actual application, was that the "OnClientFocus" property was set to an invalid value. This was apparently causing a script error that prevented the web service from being called on the page. It also prevented the ItemsRequested event from firing, which is why I could not get the RadComboBox to work using either interface. Now that I have removed that problem and also fixed the path as you suggest, the code is working.

 

   Thanks.

   Rick.

Tags
ComboBox
Asked by
Rick
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Rick
Top achievements
Rank 2
Share this question
or