怎么让AutoCompleteExtender支持选中项的Id ? 怎么让AutoCompleteExtender支持选中项的Id? 百度上查了查,还是没给搞出来?请教大虾们 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 页面放一个哈希表存AutoCompleteExtender所有值选中的时候用哈希表匹配键值就哦了。 解决方法:前台:<table width="100%"> <tr> <td align="left" style=" border:0px;"><asp:TextBox ID="txtShipmentsUnit" Width="100%" runat="server" MaxLength="50"></asp:TextBox></td> <td align="left" style=" border:0px;"><ajaxToolkit:AutoCompleteExtender ID="autoShipmentsUnit" runat="server" ServiceMethod="GetLogisticsUnitList" ServicePath="/WebService/GetLogisticsUnit.asmx" MinimumPrefixLength="1" FirstRowSelected="true" Enabled="true" EnableCaching="false" CompletionSetCount="10" TargetControlID="txtShipmentsUnit" CompletionInterval="100" UseContextKey="true" OnClientItemSelected="OnACEItemSelected"> </ajaxToolkit:AutoCompleteExtender></td> <td align="left" style=" border:0px;"><input id="AutoComplete_Hidden" type="hidden" runat="server" /></td></tr></table>JSfunction OnACEItemSelected(source, eventArgs) {// document.getElementById("AutoComplete_Hidden").value = eventArgs.get_value(); alert("Value值:" + eventArgs.get_value() + "\nText值:" + eventArgs.get_text()); } cs代码/// <summary> /// GetLogisticsUnit 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 [System.Web.Script.Services.ScriptService] public class GetLogisticsUnit : System.Web.Services.WebService { [System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod] public string[] GetLogisticsUnitList(string prefixText, int count) { List<string> items = new List<string>(count); DataTable dt = DaTuHeJiaoHua.BLL.BaseSetting.基础_部门.GetDataTable(new Entity.BaseSetting.基础_部门查询 { 部门名称LikeEX = prefixText, 状态 = Entity.Common.State.可编辑.ToString() }); if (dt != null && dt.Rows.Count > 0) { if (dt.Rows.Count < count) { count = dt.Rows.Count; } foreach (DataRow dr in dt.Rows) { items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dr["部门名称"].ToString(), dr["部门ID"].ToString())); } return items.ToArray(); } else { return null; } } } WebMethod(EnableSession =true url转向问题,在线等 关于页面上的ViewState 导出文件名问题 给我个理由选择ajax 在asp.net中如何使用函数getTcpTable? 请问,如何实现文本的首行缩进和分段呢? C#,如何实现两个内存表的左联接以及内存表的分组?高分相送!!!急 自定义控件不放在APP_code文件夹里,会不会被编译成.dll文件? 上传图片时出现Server Error in '/' Application 急!!asp.net的repeater控件里怎么循环? 关于hmailserver修改邮箱地址及删除邮箱的操作
前台:<table width="100%">
<tr>
<td align="left" style=" border:0px;"><asp:TextBox ID="txtShipmentsUnit" Width="100%" runat="server" MaxLength="50"></asp:TextBox></td>
<td align="left" style=" border:0px;"><ajaxToolkit:AutoCompleteExtender ID="autoShipmentsUnit" runat="server" ServiceMethod="GetLogisticsUnitList"
ServicePath="/WebService/GetLogisticsUnit.asmx" MinimumPrefixLength="1" FirstRowSelected="true" Enabled="true" EnableCaching="false"
CompletionSetCount="10" TargetControlID="txtShipmentsUnit" CompletionInterval="100" UseContextKey="true" OnClientItemSelected="OnACEItemSelected">
</ajaxToolkit:AutoCompleteExtender></td>
<td align="left" style=" border:0px;"><input id="AutoComplete_Hidden" type="hidden" runat="server" /></td>
</tr></table>JSfunction OnACEItemSelected(source, eventArgs) {
// document.getElementById("AutoComplete_Hidden").value = eventArgs.get_value();
alert("Value值:" + eventArgs.get_value() + "\nText值:" + eventArgs.get_text());
}
cs代码/// <summary>
/// GetLogisticsUnit 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class GetLogisticsUnit : System.Web.Services.WebService
{
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetLogisticsUnitList(string prefixText, int count)
{
List<string> items = new List<string>(count);
DataTable dt = DaTuHeJiaoHua.BLL.BaseSetting.基础_部门.GetDataTable(new Entity.BaseSetting.基础_部门查询 { 部门名称LikeEX = prefixText, 状态 = Entity.Common.State.可编辑.ToString() });
if (dt != null && dt.Rows.Count > 0)
{
if (dt.Rows.Count < count)
{
count = dt.Rows.Count;
} foreach (DataRow dr in dt.Rows)
{
items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dr["部门名称"].ToString(), dr["部门ID"].ToString()));
}
return items.ToArray();
}
else
{
return null;
}
}
}