自动完成Extender不调用webservice方法

时间:2011-04-05 06:13:13

标签: asp.net

自动完成Extender未调用webservice方法...

确切的问题是。,我在Example项目中使用AutoComplet Extender工作正常..但是在我的live项目中使用的相同代码(aspx代码以及webservice代码)它没有调用Web服务方法...

我的直播项目是dotnet 2.0版

我在下面提到我的代码

  • aspx代码

            

  • asmx代码

<%@ WebService Language =“C#”CodeBehind =“〜/ App_Code / WebSDoctor.cs”Class =“WebService”%>

  • asmx.cs

            

<%@ WebService Language =“C#”CodeBehind =“〜/ App_Code / WebSDoctor.cs”Class =“WebService”%>

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for WebServiceGetDoctor
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebServiceGetDoctor : System.Web.Services.WebService {
public WebServiceGetDoctor () {

    //Uncomment the following line if using designed components 
    //InitializeComponent(); 
}

[System.Web.Services.WebMethod]
public string[] GetDoctorName(string prefixText, string contextKey)
{
    string target = contextKey;
    SqlConnection sqlconn = new SqlConnection(@"Data Source=ABMSPLWINSRV2\ABMSPL;Initial Catalog=VivusHIS;Persist Security Info=True;User ID=sa; pwd=Bgs2000new");

    SqlCommand sqlcmd = new SqlCommand();
    sqlcmd.CommandType = CommandType.StoredProcedure;
    sqlcmd.CommandText = "SerchGetDoctorDetails";
    SqlParameter p = new SqlParameter();
    sqlcmd.Connection = sqlconn;
    p = sqlcmd.Parameters.AddWithValue("@prefixText", prefixText);
    p = sqlcmd.Parameters.AddWithValue("@target", target);
    SqlDataAdapter da = new SqlDataAdapter(sqlcmd);
    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[target].ToString(), i);

        if (i != 10)
        {
            i++;
        }

    }
    return items;
}

}

2 个答案:

答案 0 :(得分:0)

您是否尝试Class="WebServiceGetDoctor"而不是Class="WebService"

答案 1 :(得分:0)

添加此行

[System.Web.Script.Services.ScriptService]
行后

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]