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 ...
随机推荐
- hadoop入门篇-hadoop下载安装教程(附图文步骤)
在前几篇的文章中分别就虚拟系统安装.LINUX系统安装以及hadoop运行服务器的设置等内容写了详细的操作教程,本篇分享的是hadoop的下载安装步骤. 在此之前有必要做一个简单的说明:分享的所有内容 ...
- Centos 配置ifconfig命令
刚装完CentOS 后ifconfig命令可能是不可用的,那么需要以下配置 ip addr vi /etc/sysconfig/network-scripts/ifcfg-xx (ONBOOT=yes ...
- OOD与OOP的思想的感悟
Walking on water and developing software from a specification are easy if both are frozen) -Edward V ...
- Guid 几种格式化
//32 位数字:00000000000000000000000000000000 Console.WriteLine(Guid.NewGuid().ToString("N")); ...
- bzoj4161: Shlw loves matrixI
Description 给定数列 {hn}前k项,其后每一项满足 hn = a1*h(n-1) + a2*h(n-2) + ... + ak*h(n-k) 其中 a1,a2...ak 为给定数列.请计 ...
- [转]关于vs2005、vs2008和vs2010项目互转的总结
关于vs2005.vs2008和vs2010项目互转的总结 分类: Asp.Net2010-11-16 16:59 18239人阅读 评论(12) 收藏 举报 2010.net框架编译器 有做.net ...
- 一份CTR的特征工程图
- Spark学习笔记5:Spark集群架构
Spark的一大好处就是可以通过增加机器数量并使用集群模式运行,来扩展计算能力.Spark可以在各种各样的集群管理器(Hadoop YARN , Apache Mesos , 还有Spark自带的独立 ...
- 6.26-EL表达式,JSTL标签
一.EL表达式 功能: 替代jsp中数据访问时的复杂java代码 语法: ${表达式} ${(5+9)*2} 访问顺序: page--->request--->session---> ...
- sklearn-MultinomialNB朴素贝叶斯分类器
原型 class sklearn.naive_bayes.MultinomialNB(alpha=1.0, fit_prior=True, class_prior=None) 参数 Parameter ...