ASP.NETAutocomplete control
分享一个Ajax autocomplete control,
原文链接:http://forums.asp.net/t/1157595.aspx
首先,引入ScriptManager
<asp:ScriptManager ID="mainScriptManager" runat="server" />
Create 一个TextBox, 这里我把它命名为txtAutoComplete
<asp:TextBox ID="txtAutoComplete" runat="server" Width="98%" Text=''></asp:TextBox>
然后,拖入一个AutoCompleteExtender, 设置
TargetControlID="txtAutoComplete", 将AutoComplete control 和textBox链接起来
ServicePath="AutoCompletedWebService.asmx", 指定WebService
ServiceMethod="LoadValues", 指定方法
MinimumPrefixLength="2", 输入多少字符时,开始执行方法,这里指定的2个
CompletionSetCount="20",指定最多多少个值会被列出来
UseContextKey="true", 指定是否使用输入作为参数
CompletionInterval="100", 指定Ajax post 时间
CompletionListCssClass="autocomplete_completionListElement" 设置List的样式
CompletionListItemCssClass="autocomplete_listItem",设置每个ITEM的样式
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" , 设置高亮样式
FirstRowSelected="true",设置首行选中效果
EnableCaching="true" ,使用Cache
OnShow,OnHide, 设置动画效果
<cc1:AutoCompleteExtender ID="aceMinSupplierID" runat="server" TargetControlID="txtAutoComplete" BehaviorID="AutoCompleteEx"
ServicePath="AutoCompletedWebService.asmx" ServiceMethod="LoadValues" MinimumPrefixLength="2"
CompletionSetCount="20" UseContextKey="true" Enabled="true" CompletionInterval="100"
CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" FirstRowSelected="true"
EnableCaching="true" >
<Animations>
<OnShow>
<Sequence>
<%-- Make the completion list transparent and then show it --%>
<OpacityAction Opacity="0" />
<HideAction Visible="true" /> <%--Cache the original size of the completion list the first time
the animation is played and then set it to zero --%>
<ScriptAction Script="
// Cache the size and setup the initial size
var behavior = $find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" /> <%-- Expand from 0px to the appropriate size while fading in --%>
<Parallel Duration=".4">
<FadeIn />
<Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
</Parallel>
</Sequence>
</OnShow>
<OnHide>
<%-- Collapse down to 0px and fade out --%>
<Parallel Duration=".4">
<FadeOut />
<Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
</Parallel>
</OnHide>
</Animations>
</cc1:AutoCompleteExtender>
CSS样式设计
/*AutoComplete flyout */
.autocomplete_completionListElement
{
margin : 0px!important;
background-color : inherit;
color : windowtext;
border : buttonshadow;
border-width : 1px;
border-style : solid;
cursor :default;
overflow : auto;
height : 200px;
text-align : left;
list-style-type : none;
padding-left:0px;
} /* AutoComplete highlighted item */ .autocomplete_highlightedListItem
{
background-color: #ffff99;
color: black;
padding: 1px;
} /* AutoComplete item */ .autocomplete_listItem
{
background-color : window;
color : windowtext;
padding : 1px;
}
Web Service 代码,Imports System.Web.ServicesImports System.Web.Services.Protocols
Imports System.ComponentModel' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class AutoCompletedWebService
Inherits System.Web.Services.WebService <WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function <WebMethod()>
<System.Web.Script.Services.ScriptMethod()> _
Public Function LoadMinSupplierID(ByVal prefixText As String, ByVal contextKey As String) As String()
Dim list As New List(Of String)()
list.Clear()
......
取得数据
......
Return list.ToArray()
End Function
End Class
ASP.NETAutocomplete control的更多相关文章
- ASP.NET项目中使用CKEditor +CKFinder 实现上传图片
CKEditor是什么 CKEidtor是一个在线富文本编辑器,可以将让用户所见即所得的获得编辑在线文本,编辑器或自动将用户编辑的文字格式转换成html代码. 在ASP.NET工程中添加CKEdito ...
- ASP.NET 文本编辑器使用(CKEditor)与上传图片
CKEditor是什么 CKEidtor是一个在线富文本编辑器,可以将让用户所见即所得的获得编辑在线文本,编辑器或自动将用户编辑的文字格式转换成html代码. 方法一.在ASP.NET工程中添加CKE ...
- 在ASP.NET项目中使用CKEditor
CKEditor是什么 CKEidtor是一个在线富文本编辑器,可以将让用户所见即所得的获得编辑在线文本,编辑器或自动将用户编辑的文字格式转换成html代码. 在ASP.NET工程中添加CKEdito ...
- Edit Individual GridView Cells in ASP.NET
Edit individual GridView cells without putting the entire row into edit mode.Examples using the SqlD ...
- Ajax Control Toolkit 34个服务器端控件的使用
摘自:http://blog.csdn.net/yaoshuyun/article/details/2218633 1. Accordion[功能概述] Accordion可以让你设计多个panel ...
- Asp.net网页中DataGridView数据导出到Excel
经过上网找资料,终于找到一种可以直接将GridView中数据导出到Excel文件的方法,归纳方法如下: 1. 注:其中的字符集格式若改为“GB2312”,导出的部分数据可能为乱码: 导出之前需要关闭分 ...
- A Complete List of .NET Open Source Developer Projects
http://scottge.net/2015/07/08/a-complete-list-of-net-open-source-developer-projects/?utm_source=tuic ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q52-Q55)
Question 52You are responsible for rebranding the My Sites section of a corporate SharePoint 2010 fa ...
- Step-by-Step Guide to Portal Development for Microsoft Dynamics CRM - 摘自网络
The Challenge Oftentimes in the world of Dynamics CRM, the need arises for non-CRM users to gain acc ...
随机推荐
- mysql编译安装(详细)
一.编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl 安装cmake,从http://www.cmake ...
- 带你走进Linux(Ubuntu)
类Unix系统目录结构 ubuntu没有盘符这个概念,只有一个根目录/,所有文件都在它下面 /:根目录,一般根目录下只存放目录,在Linux下有且只有一个根目录.所有的东西都是从这里开始.当你在终端里 ...
- C# 教程
http://www.runoob.com/csharp/csharp-tutorial.html
- SQL 实践和技巧 <2>
转自 http://i.cnblogs.com/EditPosts.aspx?opt=1 几个小技巧 (1)||的使用: select ‘(‘||phone[1,3]||’)’phone[5, ...
- Network Emulator Toolkit (NEWT) 网络限速工具 (手机和电脑方面)
下载地址: https://blog.mrpol.nl/2010/01/14/network-emulator-toolkit/ 参考博客: http://blog.csdn.net/lluozh20 ...
- 基于Vue的Ui框架
基于Vue的Ui框架 饿了么公司基于vue开的的vue的Ui组件库 Element Ui 基于vue pc端的UI框架 http://element.eleme.io/ MintUi 基于vue 移动 ...
- 批处理-通过mono把c#编译成dll
::copyright@cjy @echo off ::mcs.exe address set addrMcs=D:\Program Files\Unity\Editor\Data\MonoBleed ...
- 【BZOJ】1101 [POI2007]Zap(莫比乌斯反演)
题目 传送门:QWQ 分析 莫比乌斯反演. 还不是很熟练qwq 代码 //bzoj1101 //给出a,b,d,询问有多少对二元组(x,y)满足gcd(x,y)=d.x<=a,y<=b # ...
- sqoop操作之HDFS导出到ORACLE
注意:在导出前需要先创建待导出的表结构.如果导出的表在数据库中不存在则会报错:如果重复导出多次,表中的数据会重复: ; ; 导出表的所有字段 sqoop export --connect jdbc:o ...
- Spark分析之Worker
override def preStart() { webUi = new WorkerWebUI(this, workDir, Some(webUiPort)) webUi.bind() //创建并 ...