ajax自动搜索功能

<textarea cols="50" rows="15" name="code" class="c-sharp"> 页面: &lt;asp:TextBox ID="txt_place" runat="server" class="inputkprice"&gt;&lt;/asp:TextBox&gt; &lt;cc1:AutoCompleteExtender ID="txt_place_AutoCompleteExtender" runat="server" DelimiterCharacters="" ServicePath="" ServiceMethod="GetCarCompletionList" UseContextKey="True" MinimumPrefixLength="1" TargetControlID="txt_place"&gt; &lt;/cc1:AutoCompleteExtender&gt; 后台: [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string[] GetCarCompletionList(string prefixText, int count, string contextKey) { ObjModelDataSource&lt;CAR_加油卡&gt; obj = new ObjModelDataSource&lt;CAR_加油卡&gt;(CAR_加油卡.DBNAME, count, CAR_加油卡.COL_办卡地点 + " like '%" + prefixText + "%'"); string[] str = null; if (obj != null &amp;&amp; obj.Count &gt; 0)//obj.DataObjectSource.Tables[0].Rows.Count=obj.Count(但是obj.Count会有问题) { str = new string[obj.GetCount()]; int nN = 0; foreach (CAR_加油卡 item in obj) { str[nN] = item.办卡地点; nN++; } } return str; } /// &lt;summary&gt; /// 司机姓名查询 /// &lt;/summary&gt; [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string[] GetDriverName(string prefixText, int count, string contextKey) { ObjModelDataSource&lt;CAR_司机资料&gt; obj = new ObjModelDataSource&lt;CAR_司机资料&gt;(CAR_司机资料.DBNAME, count, "司机姓名 like '%" + prefixText + "%'"); string[] str = null; if (obj != null &amp;&amp; obj.DataObjectSource.Tables[0].Rows.Count &gt; 0) { str = new string[obj.DataObjectSource.Tables[0].Rows.Count]; int nN = 0; foreach (CAR_司机资料 item in obj) { str[nN] = item.司机姓名; nN++; } } return str; }</textarea>

你可能感兴趣的:(Ajax,server,String,null,asp,textbox)