私は過去3時間部品にこだわっています。インターネットで検索したり、ブログを読んだり、コードや例を調べたりテストしたりしましたが、何も得られませんでした。
テキストボックスで Ajax Control Toolkit の Ajax Auto Complete Extender を使用しており、ユーザーが入力したテキストに基づいてデータベースから最も少ない問題を生成したいと考えています。
このために、私はWebサービスを作成しました。Web サービスのメソッドは -
namespace CeteraQMS
{
/// <summary>
/// Summary description for SearchIssues
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class SearchIssues : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod]
public string[] GetCompletionList(string prefixText, int count)
{
DataSet ds = null;
DataTable dt = null;
OracleConnection conn = null;
StringBuilder sb = new StringBuilder();
try
{
conn = new OracleConnection("Data Source=advbniit; User ID=usr; Password=abc providerName=System.Data.OracleClient");
sb.Append("select issueno from cet_sepcet where issueno like '");
sb.Append(prefixText);
sb.Append("%'");
OracleDataAdapter daRes = new OracleDataAdapter(sb.ToString(), conn);
ds = new DataSet();
daRes.Fill(ds);
dt = ds.Tables[0];
}
catch (Exception exc)
{
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
List<string> IssueList = new List<string>();
for (int i = 0; i < dt.DataSet.Tables[0].Rows.Count; i++)
{
IssueList.Add(dt.DataSet.Tables[0].Rows[i][0].ToString());
}
return IssueList.ToArray();
}
}
私はこのWebサービスを次のように呼んでいます-
<asp:TextBox ID="txtIssueNo" runat="server" Width="130px" Style="margin-left: 5px"
onkeypress="return allowDigit(this);" MaxLength="7"></asp:TextBox>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" EnableCaching="true" BehaviorID="AutoCompleteCities"
TargetControlID="txtIssueNo" ServiceMethod="GetCompletionList" ServicePath="SearchIssues.asmx"
MinimumPrefixLength="1" CompletionSetCount="10" runat="server" FirstRowSelected="true">
</asp:AutoCompleteExtender>
純粋でシンプル。しかし、驚いたことに、テキストボックスにテキストを入力しても何も起こりません。どこが間違っているかのように私を導いてください。
前もって感謝します
PS - エラーは発生していません。