本文介绍了AutoCompletExtender不调用Webservice方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
确切的问题是.,在示例项目中使用AutoComplet Extender可以正常工作..但是在我的实时项目中使用的相同代码(aspx代码以及Web服务代码)没有调用Web服务方法...
我的现场项目是dotnet 2.0版本
我提到了下面的代码
aspx代码
the exact problem is ., Am using AutoComplet Extender in Example project its working fine .. but the same code(aspx code as well as webservice code) am using in my live project its not calling the web service method ...
my live project is dotnet 2.0 version
i mention my code bellow steps
aspx Code
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server" Width="293px" autocomplete="off"
AutoPostBack ="true" ontextchanged="TextBox1_TextChanged1" Height="16px" ></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
ServiceMethod ="GetDoctorName" ServicePath="WebSDoctor.asmx" MinimumPrefixLength ="1" UseContextKey ="true"
ContextKey ="DoctorName" TargetControlID="TextBox1" >
</cc1:AutoCompleteExtender>
asmx代码
asmx code
<%@ WebService Language="C#" CodeBehind="~/App_Code/WebSDoctor.cs" Class="WebService" %>
asmx.cs
asmx.cs
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;
}
}
推荐答案
这篇关于AutoCompletExtender不调用Webservice方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!