鉴于大家对ASP.net十分关注,我们编辑小组在此为大家搜集整理了“自动填充控件AutoCompleteExtender控件实现代码”一文,供大家参考学习
AutoCompleteProperties的属性包括
属性名称 | 属性描述 | 备注 |
TargetControlID | 指定要控制的控件的ID | 一般为TextBox的ID |
ServicePath | 处理智能选择列表的Web Services路径 | |
ServiceMethod | 处理智能选择列表的网络服务服务 | 该方法一般包含两个参数(string prefixText, int count) |
Enabled | 是否可用 | |
MinimumPrefixLength | 最小前缀的长度大小 | 当输入长度达到最小的时候,便提供智能选择 |
一、查看web.config文件中是否存在如下配置(倘若没有请添加):
<system.web>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<system.web>
二、代码如下:
2_SimpleList_AutoComplete_DragandDrop.aspx文件
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="2_SimpleList_AutoComplete_DragandDrop.aspx.cs"
Inherits="_2_SimpleList_AutoComplete_DragandDrop" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="WebServiceSearchName.asmx" />
</Services>
</asp:ScriptManager>
<asp:TextBox runat="server" ID="TextBoxInput" Width="300" autocomplete="off" />
<asp:AutoCompleteExtender runat="server" ID="AutoCompleteExtender1" TargetControlID="TextBoxInput"
ServicePath="webservicesearchname.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="1"
CompletionInterval="100" EnableCaching="true" CompletionSetCount="12" />
</div>
</form>
</body>
</html>
本新闻共3页,当前在第1页 1 2 3