Regarding webservice with ajax autocomplete???
-
Hi, Im using Webservice to implement autocomlpeteextender but im getting the folling error..any namespace i need to add or any changes have to do in the web config? im struggling? im getting the folling error.. Error 1 Attribute 'System.Web.Script.Services.ScriptService' is not valid on this declaration type. It is valid on 'class, interface' declarations only. Here the following code which i have used... ================================= using System; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.Data; using System.Data.SqlClient; /// <summary> /// Summary description for Auto /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Auto : System.Web.Services.WebService { public Auto () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World"; } [System.Web.Script.Services.ScriptMethod] [System.Web.Script.Services.ScriptService] [WebMethod] public string[] GetCountryInfo(string prefixText) { SqlConnection con = new SqlConnection("uid=srp;pwd=12345;server=kagserver;"); //int count = 10; string sql = "select * from student_information Where s_Name like @prefixText"; SqlDataAdapter da = new SqlDataAdapter(sql, con); da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText + "%"; DataTable dt = new DataTable(); da.Fill(dt); string[] items = new string[dt.Rows.Count]; int i = 0; foreach (DataRow dr in dt.Rows) { items.SetValue(dr["s_Name"].ToString(), i); i++; } return items; } } ============================= <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Autocomplete.aspx.cs" Inherits="Autocomplete" %> <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
Hi, Im using Webservice to implement autocomlpeteextender but im getting the folling error..any namespace i need to add or any changes have to do in the web config? im struggling? im getting the folling error.. Error 1 Attribute 'System.Web.Script.Services.ScriptService' is not valid on this declaration type. It is valid on 'class, interface' declarations only. Here the following code which i have used... ================================= using System; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.Data; using System.Data.SqlClient; /// <summary> /// Summary description for Auto /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Auto : System.Web.Services.WebService { public Auto () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World"; } [System.Web.Script.Services.ScriptMethod] [System.Web.Script.Services.ScriptService] [WebMethod] public string[] GetCountryInfo(string prefixText) { SqlConnection con = new SqlConnection("uid=srp;pwd=12345;server=kagserver;"); //int count = 10; string sql = "select * from student_information Where s_Name like @prefixText"; SqlDataAdapter da = new SqlDataAdapter(sql, con); da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText + "%"; DataTable dt = new DataTable(); da.Fill(dt); string[] items = new string[dt.Rows.Count]; int i = 0; foreach (DataRow dr in dt.Rows) { items.SetValue(dr["s_Name"].ToString(), i); i++; } return items; } } ============================= <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Autocomplete.aspx.cs" Inherits="Autocomplete" %> <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">