I have a webpart which calls ASP.NET handler to accomplish the autocomplete functionality.
ASHX File
<%@ WebHandler Language="C#" Class="MyService.MyAutoComplete" CodeBehind="MyAutoComplete.ashx.cs" %>
Code Behind File
namespace MyService
{
/// <summary>
/// Summary description for MyAutoComplete
/// </summary>
public class MyAutoComplete : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var searchTerm = context.Request.QueryString["term"].ToString();
context.Response.Clear();
context.Response.ContentType = "application/json";
var search = GetList();
JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
string json = jsSerializer.Serialize(search);
context.Response.Write(json);
context.Response.End();
}
}
}
This is my JQuery call
$(function () {
$("#<%= txtSearchInput.ClientID %>").autocomplete({
source: "/_Layouts/My Service/MyAutoComplete.ashx",
minLength: 2,
select: function (event, ui) {
$(this).val(ui.item.value);
}
});
});
The “My Service” is SharePoint layout folder inside the webpart project.
When I make call thro JQuery it throws the following error
“Could not create type ‘MyService.MyAutoComplete'”
Any help appreciated.
It Seems SharePoint components have its own way of identifying the components :). After googling I found the following solution.