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

RadAutoCompleteBox works on localhost but not when published.

14 Answers 249 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 16 Oct 2012, 10:37 AM
I have a project with RadAutoCompleteBox and every thing works fine on my localhost, but when I upload it the page doesn't crash but the drop down doesn't appear at all but yet it works fine on my computer.

I have the RadAutoCompleteBox binded to a web service.

When I go to the web service page online I get the following error. 

Cannot serialize member Telerik.Web.UI.AutoCompleteBoxData.Context of type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], because it implements IDictionary.


Here is my code in the web service.
using ClassLibrary;
// uses the class library
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI.AutoCompleteBox;
using System.Web.Services;
using Telerik.Web.UI;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
 
 
//using System.Collections;
//using System.Runtime.Serialization;
//using System.Runtime.Serialization.Formatters.Binary;
 
 
namespace ReportsViewer.Services
{
    /// <summary>
    /// Web service for telerik autocompletebox
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
     
    public class StaffWebService : System.Web.Services.WebService
    {
        string QueryData {get; set;}
        string AcademicYear { get; set; }
 
        [WebMethod(EnableSession = true)]
 
        public AutoCompleteBoxData GetStaffNames(object context)
        {
            //Orignal code
            //QueryData = context["Text"].ToString();
            //var AcademicYear = Session["AcademicYear"];
 
            //Testing code
            string QueryData = ((IDictionary<string, object>)context)["Text"].ToString();
            var AcademicYear = Session["AcademicYear"];
 
                using (SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Connect"].ConnectionString))
                {
                cn.Open();
                using (SqlCommand cm = cn.CreateCommand())
                {
                    cm.CommandText = "sql stuff";
                     
                    cm.Parameters.AddWithValue("@QueryData", QueryData);
                    cm.Parameters.AddWithValue("@AcademicPeriod", AcademicYear);
                     
                    using (SqlDataAdapter objAdpt = new SqlDataAdapter())
                    {
                        objAdpt.SelectCommand = cm;
 
                        using (DataTable dt = new DataTable())
                        {
                            objAdpt.Fill(dt);
                            dt.DefaultView.Sort = "Name";
 
                            List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();
                            AutoCompleteBoxData dropDownData = new AutoCompleteBoxData();
 
                            result = new List<AutoCompleteBoxItemData>();
 
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                AutoCompleteBoxItemData itemData = new AutoCompleteBoxItemData();
                                itemData.Text = dt.Rows[i]["Name"].ToString();
                                itemData.Value = dt.Rows[i]["WINDOWS_USER_ID"].ToString();
 
                                result.Add(itemData);
                            }
 
                            dropDownData.Items = result.ToArray();
                            return dropDownData;
      
                        }
                             
                    }
                         
                     
                }
 
            }
        }
         
    }//end of class
}//end of namespace

Cheers

John Moore

14 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 17 Oct 2012, 10:29 AM

When I have the following.

public AutoCompleteBoxData GetStaffNames(object context)

 

It works fine on the aspx page and the drop down appears but when I go to the web service page it shows
The type Telerik.Web.UI.RadAutoCompleteContext is not supported because it implements IDictionary. 
But it works.

When I make it. 
public static AutoCompleteBoxData GetStaffNames(object context)

The web service is fixed and no errors but when I run the axpx page no drop down appears.

This problem is doing my head in, any help would be gladly appreciated.
 
Thanks

John Moore

0
John
Top achievements
Rank 1
answered on 18 Oct 2012, 01:51 PM
After 5 days of this problem doing my head in and have tried everything I went to the telerik tab in visual studio and went to  
RadControls for asp.net AJAX and went to the upgrade wizard because I was bored.

Published the site and guess what it worked on webhost even thou if I go to the web service directly it doesn't work and says about Idictionary.

The type Telerik.Web.UI.RadAutoCompleteContext is not supported because it implements IDictionary.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The type Telerik.Web.UI.RadAutoCompleteContext is not supported because it implements IDictionary.

Source Error:
[NotSupportedException: The type Telerik.Web.UI.RadAutoCompleteContext is not supported because it implements IDictionary.]
   System.Xml.Serialization.TypeScope.GetDefaultIndexer(Type type, String memberInfo) +5529598
   System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, MemberInfo memberInfo, Boolean directReference) +885
   System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError) +153
   System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +73
   System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +286



This must be a major problem with this control connected to a webservice.
0
Kalina
Telerik team
answered on 18 Oct 2012, 02:26 PM
Hello John,

The issue that you describe is quite strange.
Populating the RadAutoCompleteBox with data via WebService works properly on our online demo here.

I simplified your web service implementation and prepared a very basic sample – could you please download it and test it on your side?

Maybe there is something specific in your project (or implementation) that causes the issue?
I believe that a working sample on your side will help you to find it.

Regards,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
John
Top achievements
Rank 1
answered on 19 Oct 2012, 08:07 AM
I downloaded you files and created a new project.

When I run it

Error Message.

Microsoft JScript runtime error: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: baseType

Line number 786 - In

 
MicrosoftAjax.debug.js
Version: 4.0.0.0

FileVersion: 4.0.30319.17929


At the the throw Error.argumentUndefind('baseType');
if ((arguments.length > 1) && (typeof(baseType) === 'undefined')) throw Error.argumentUndefined('baseType');

I am using visual studio 2010 - Version 10.0.40219.1 sp1Rel
.NET Framework version 4.5.50709 sp1 rel
Windows 7

0
Kalina
Telerik team
answered on 23 Oct 2012, 04:35 PM
Hello John,

The sample web site that I have provided you works properly on my side - please take a look at this demonstration video.
Did you change the sample web site before running it?
Where did you receive the error - on your development machine or on the server where you publish the website?

Regards,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Ganapathy
Top achievements
Rank 1
answered on 11 Oct 2013, 03:50 PM
Hi Team,

This sample is working in my system.

Thank You
Regards
Ganapathy (Gunny)
0
Tomasz
Top achievements
Rank 1
answered on 15 Jan 2014, 02:44 PM
I have the same issue.
On my dev machine it works fine but after publishing to my hosting the control doesn't work.
I'm using SQL Data Source, I've EF and OpenAccess also with the same results...

No errors, no nothing...
0
Plamen
Telerik team
answered on 20 Jan 2014, 09:30 AM
Hi Tomasz,

We are not aware of such known issue in the current version of the control. Would you please share the exact code connected with RadAutoCompleteBox that you are using so we could inspect it and be more helpful?

Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Tomasz
Top achievements
Rank 1
answered on 20 Jan 2014, 11:41 AM
Your suport is already working on it because I've provided a sample solution which was admited to have a bug in this scenario :)
0
Nessi
Top achievements
Rank 1
answered on 31 Aug 2015, 06:44 AM

Any update on this issue?

I have the same effect, getting the error about the IDoctionary when accessing the web service.

0
Plamen
Telerik team
answered on 02 Sep 2015, 06:56 AM
Hi,

We are not aware of such issue in the latest version of the controls. You can refer to this online demo where the scenario is working correctly. If you still observe the issue please elaborate the exact code that should be used to replicate it at our side.

Regards,
Plamen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Anoosh
Top achievements
Rank 1
answered on 29 Nov 2016, 07:50 PM

I am having the same issue using Telerik build: 2016.3.1027 (Dev)

Cannot serialize member Telerik.Web.UI.AutoCompleteBoxData.Context of type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], because it implements IDictionary.

Can someone help?

0
Plamen
Telerik team
answered on 01 Dec 2016, 09:54 AM
Hi,

I have tested a scenario once again with the sample page that was attached in the answer by Kalina on 18-Oct-2012 5:26:54 PM and it still worked correctly at my side.

Regards,
Plamen
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
0
David
Top achievements
Rank 1
answered on 10 Jan 2017, 11:54 PM
Without knowing as much as Telerik about their control I can only surmise from what one poster is saying is that when you try and attach to your webservice it, auto.., can't use the data because its implements a dictionary object.

My first guess is that your webservice is not providing you the two pieces of data to create a dictionary object which is what it needs. If you look at the auto box you have to give it a value and text field. If your WS only returns one it will fail.

Create a class that takes two pieces of data. One a integer for a counter and the other a string for your data. When you grab the data JSON or XML add it to your class. As you loop the WS data increment a counter. Now you have a object, you can attach to your autocomplete box with both pieces of information that it needs. Make sure to set the text/value fields on the autobox to whatever you called them in your class.

Don't know if that works without testing it but I see no reason why it wouldn't.
Tags
AutoCompleteBox
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Kalina
Telerik team
Ganapathy
Top achievements
Rank 1
Tomasz
Top achievements
Rank 1
Plamen
Telerik team
Nessi
Top achievements
Rank 1
Anoosh
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or