
I’m using a web service to feed the search as you type combo box on my page. If the search returns 0 results I get the following error:
Microsoft Jscript runtime error: ‘Items’ is null or not an object
It works fine if results are returned. Below is the code for the RadComboBox and below that is the web service method I’m using. Any assistance would be greatly appreciated.
Experienced this problem with both 2010 Q1 and now Q2 Beta.
RadComboBox Snippet:
<telerik:RadComboBox ID="rcmbClients" runat="server" EnableLoadOnDemand="true"
ShowMoreResultsBox="true" EnableVirtualScrolling="true"
TabIndex="1" EnableItemCaching="true" EnableViewState="false" EmptyMessage="-- enter text --"
NoWrap="true" ShowWhileLoading="false"
OnSelectedIndexChanged="rcmbClients_SelectedIndexChanged"
AutoPostBack="true" Width="500" WebServiceSettings-Method="GetFilteredClients"
Filter="Contains" ItemRequestTimeout="300" WebServiceSettings-Path="~/RadService.svc"
AllowCustomText="true">
</telerik:RadComboBox>
Web Service Snippet:
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class RadService
{
[OperationContract]
public RadComboBoxData GetFilteredClients(RadComboBoxContext context)
{
try
{
RadComboBoxData result = new RadComboBoxData();
ClientBL clientBL = new ClientBL(); IList<ShortClient> clients = clientBL.GetFilteredShortClients(context.Text.Replace("%", "[%]").Replace("&squote", "[']"));
IEnumerable<RadComboBoxItemData> allDataItems = from client in clients
select new RadComboBoxItemData()
{
Text = client.DisplayName,
Value = client.ID.ToString()
};
int numberOfItems = context.NumberOfItems;
IEnumerable<RadComboBoxItemData> pageOfDataItems = allDataItems.Skip(numberOfItems).Take(500);
result.Items = pageOfDataItems.ToArray();
int endOffSet = numberOfItems + pageOfDataItems.Count();
int totalCount = allDataItems.Count();
if (endOffSet == totalCount)
result.EndOfItems = false;
result.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffSet, totalCount);
return result;
}
catch (Exception ex)
{
string target = context.Text;
LogManager logManager = new LogManager();
logManager.Log(TraceEventType.Error, "Search Criteria Submitted By User: \"" + context.Text + "\"" + Environment.NewLine + ex.Message.ToString());
throw;
}
}
12 Answers, 1 is accepted
We are aware of this issue and will fix in the future versions of RadComboBox. Thank you for your involvement.
Greetings,
Simon
the Telerik team

You are perfectly right - this is a fundamental issue. We will fix it this during this and the next week.
Regards,
Simon
the Telerik team

We actually fixed the issue.
Can you please make sure that you have properly upgraded to the new version, i.e. no references to Telerik.Web.UI are cached?
If the version is correct, please describe in more detail the exact setup that is triggering the error as it may be a different one.
All the best,
Simon
the Telerik team

Yes, it is strange, the control works perfectly until i type a value (last name) that returns 0 items. then i get the following error:
"Microsoft JScript runtime error: 'Items' is null or not an object" (Break/Continue/Ignore)
More details:
VS 2010
Project References: C:\Program Files (x86)\Telerik\RadControls for ASP.NET AJAX Q2 2010\Bin40\Telerik.Web.UI.dll (version 2010.2.713.40)
Cleared debug / release / bin folder and rebuilt project. that didn't help.
Sample Code:
web page:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<div>
<telerik:RadComboBox ID="RadComboBox1" runat="server" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
MarkFirstMatch="true" EmptyMessage="Type here...">
<WebServiceSettings Method="GetClientList" Path="Services/ListService.svc" />
</telerik:RadComboBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<select id="test">
</select>
</div>
Web Service:
public class ListItem
{
public int ID { get; set; }
public string Text { get; set; }
}
[OperationContract]
public Telerik.Web.UI.RadComboBoxData GetClientList(Telerik.Web.UI.RadComboBoxContext context)
{
RadComboBoxData result = new RadComboBoxData()
Model.DbContext db = new Model.DbContext();
var allItems = (from d in db.Clients
orderby d.LastName
select new ListItem
{
ID = d.DirID,
Text = d.LastName
});
string filter = context.Text;
if (!String.IsNullOrEmpty(filter))
{
allItems = allItems.Where(d => d.Text.StartsWith(filter));
}
// perform the paging
int numberOfItems = context.NumberOfItems;
var items = allItems.Skip(numberOfItems).Take(10);
// execute database query
List<ListItem> tmpItems = items.ToList();
result.Items = tmpItems.Select(d => new RadComboBoxItemData() { Text = d.Text, Value = d.ID.ToString() }).ToArray();
int endOffset = numberOfItems + items.Count();
int totalCount = allItems.Count();
if (endOffset == totalCount) result.EndOfItems = true;
//Initialize the status message
result.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset, totalCount);
return result;
}

-i uninstalled the RadControls from my machine,
-i cleared my browser cache,
-i rebooted.
-I reinstalled the RadControls from the trial downloads.
-I deleted the \bin and \obj directories in my project,
-I rebuilt the project.
...and I still get the error. Any chance the RadControls Trial install has the old buggy version?
The Trial and Dev versions are exactly the same in terms of functionality.
I just verified the case with the latest version of Telerik.Web.UI and can confirm that it works properly. In this demo, I modified the WCF service to not set the Items property of the RadComboBoxData object and the RadComboBox handled this without an error on the client side.
Can you please open the HTML source of the page and search for '2010.' - this will show the version of Telerik.Web.UI which is actually used on the page?
Kind regards,
Simon
the Telerik team

Okay, here's my html page. Pretty simple...it's got the radcombo and a scriptmanager control. I did not find a reference to 2010. I also attached a version screenshot of the telerik.we.ui in my project reference...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CP.Web.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadComboBox ID="RadComboBox1" runat="server" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
MarkFirstMatch="true" EmptyMessage="Type here...">
<WebServiceSettings Method="GetClientList" Path="Services/ListService.svc" />
</telerik:RadComboBox>
</div>
</form>
</body>
</html>


The bug is fixed in Q2 2010 (version 2010.2.713) and later. The procedure of re-referencing the Telerik.Web.UI assembly is required only if the assembly has been cached and after upgrading you continue to see the issue. Otherwise updating the assembly is enough.
Sincerely yours,
Simon
the Telerik team