Hello!
I am trying to run the demo found here but with no success (not working). I made the minimum of changes to get data from my own DB but I keep receiveing the same error saying that "The server method 'GetiPMP' failed". I already double checked path, code and I even referred to the solution showed here but no success.
My code...
PMP_WS.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="iPMP_WS.aspx.cs" Inherits="custom_scripts_iPMP_iPMP_WS" %>
<!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>
<script type="text/javascript">
function requesting(sender, eventArgs) {
var context = eventArgs.get_context();
//Data passed to the service.
context["ClientData"] = "ClientData_Passed_To_The_Service";
}
</script>
</head>
<body>
<form id="form1" runat="server" >
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadAutoCompleteBox RenderMode="Lightweight" runat="server" ID="RadAutoCompleteBox1" ClientID="RadAutoCompleteBox1"
autopostback="true"
InputType="Token" Width="100%" Visible="true"
AllowCustomEntry = "false"
DropDownWidth="300px"
onclientrequesting="requesting" >
<WebServiceSettings Path="iPMP_WS.asmx" Method="GetiPMP" />
</telerik:RadAutoCompleteBox>
</form>
</body>
</html>
iPMP_WS.asmx
<%@ WebService Language="C#" CodeBehind="~/App_Code/iPMP_WS.cs" Class="iPMP_WS" %>
iPMP_WS.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Telerik.Web.UI;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class iPMP_WS : System.Web.Services.WebService
{
public iPMP_WS()
{
}
[WebMethod]
public static AutoCompleteBoxData GetiPMP(RadAutoCompleteContext context)
{
string clientData = context["ClientData"].ToString();
string sql = "SELECT top 10 desc as 'edesc',codes as 'ecode' FROM INVENTORY";
SqlDataAdapter adapter = new SqlDataAdapter(sql,ConfigurationManager.ConnectionStrings["MyCon"].ConnectionString);
DataTable data = new DataTable();
adapter.Fill(data);
List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();
AutoCompleteBoxData dropDownData = new AutoCompleteBoxData();
result = new List<AutoCompleteBoxItemData>();
for (int i = 0; i < data.Rows.Count; i++)
{
AutoCompleteBoxItemData itemData = new AutoCompleteBoxItemData();
itemData.Text = data.Rows[i]["edesc"].ToString();
itemData.Value = data.Rows[i]["ecode"].ToString();
result.Add(itemData);
}
dropDownData.Items = result.ToArray();
return dropDownData;
}
}
Any idea?