母版頁HTML:自動完成不工作
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="PMS.master.vb" Inherits="PMS.PMS" %>
<%@ 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">
<%@ Register Src="~/Resources/UControl/UserControlMenu.ascx" TagName="UserControlMenu" TagPrefix="uc1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<link href="Resources/CSS/PostCSS.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<!--Header-->
<table border="0" background="Resources/Images/bnrCol.jpg"cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="Left" >
<img src="Resources/Images/BnrLeft.jpg" alt="">
</td>
<td align="Right">
<img src="Resources/Images/BnrRight.jpg" alt="">
</td>
</tr>
</table>
<!--Menu-->
<uc1:UserControlMenu ID="UserControlMenu1" runat="server" />
<!--Content-->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="#EBEBE2" width="100%">
<center>
<%--body+menu here --%>
<table align="center" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="white" width="100%" valign="top">
<%--body here --%>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td rowspan="2">
</td>
</tr>
<tr>
<td valign="top">
<div>
<asp:ContentPlaceHolder ID="BodyContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</td>
</tr>
</table>
<!--Footer-->
<%-- <table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="#A1BBCA" height="23" align="center">
<asp:Label ID="Label1" runat="server" CssClass="lblCaptionSmall" ></asp:Label>
</td>
</tr>
</table>--%>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
內容的HTML代碼(網頁):
<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/PMS.Master"
CodeBehind="CreateStatement.aspx.vb" Inherits="PMS.CreateStatement" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" runat="server">
<asp:TextBox CssClass="lblCaption" ID="MainGovSource" runat="server" AutoPostBack="True"
Width="300px" TabIndex="1"></asp:TextBox>
<div id="divAutoComp">
</div>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" MinimumPrefixLength="1"
ServiceMethod="GetOfficialMainCustomer" ServicePath="~/AutoComplete.asmx" TargetControlID="MainGovSource"
BehaviorID="AutoCompleteExtender1" EnableCaching="false" Enabled="True" CompletionSetCount="40"
CompletionListElementID="divAutoComp" CompletionInterval="1">
<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>
</asp:AutoCompleteExtender>
</asp:Content>
AutoComplete.asmx
VB代碼:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Collections
Imports PMS.Access
Imports PMS.Common
Imports PMS.Business
' 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 AutoComplete
Inherits System.Web.Services.WebService
Public Sub AutoComplete()
End Sub
<WebMethod(EnableSession:=True)> _
Public Function GetOfficialMainCustomer(ByVal prefixText As String, ByVal count As Integer) As String()
'--------------
Dim objCustomersBusinessController As New Business.CustomersBusinessController
Dim dsCustomers As New DSCustomer
dsCustomers = objCustomersBusinessController.LoadMainGoverment(-1)
dsCustomers.Customers.ToList()
Dim arrList() As DSCustomer.CustomersRow
arrList = dsCustomers.Customers.Select("CustomerName like '%" & prefixText & "%'")
Return arrList.Where(Function(c) c.CustomerName.ToLower().Contains(prefixText.ToLower())).[Select](Function(p) p.CustomerName).Take(400).ToArray()
End Function
End Class
CustomersBusinessController .vb
Imports PMS.Access
Imports PMS.Common
Imports System.Linq
Imports System.Text
Imports System
Public Class CustomersBusinessController
Inherits BusinessController
Dim objCustomersAccessController As CustomersAccessController = New CustomersAccessController
Public Function LoadMainGoverment(ByVal CustomerID As Integer) As DSCustomer
Return objCustomersAccessController.LoadMainGoverment(CustomerID)
End Function
End Class
CSS:
.autocomplete_completionListElement
{
visibility : hidden;
margin : 0px!important;
background-color : inherit;
color : windowtext;
border : buttonshadow;
border-width : 1px;
border-style : solid;
cursor : 'default';
overflow : auto;
height : 100px;
text-align : left;
list-style-type : none;
}
/* AutoComplete highlighted item */
.autocomplete_highlightedListItem
{
background-color: #ffff99;
color: black;
padding: 1px;
}
/* AutoComplete item */
.autocomplete_listItem
{
background-color : window;
color : windowtext;
padding : 1px;
}
/*trial for the test*/
.ContextMenuPanel
{
border: 1px solid #868686;
z-index: 1000;
background: url(images/menu-bg.gif) repeat-y 0 0 #FAFAFA;
cursor: default;
padding: 1px 1px 0px 1px;
font-size: 11px;
}
.ContextMenuBreak
{
margin:1px 1px 1px 32px;
padding:0;
height:1px;
overflow:hidden;
display:block;
border-top: 1px solid #C5C5C5;
}
a.ContextMenuItem
{
margin: 1px 0 1px 0;
display: block;
color: #003399;
text-decoration: none;
cursor: pointer;
padding: 4px 19px 4px 33px;
white-space: nowrap;
}
a.ContextMenuItem-Selected
{
font-weight: bold;
}
a.ContextMenuItem:hover
{
background-color: #FFE6A0;
color: #003399;
border: 1px solid #D2B47A;
padding: 3px 18px 3px 32px;
}
注:我使用的是AJAX版本4.1.51116.0
和
,並試圖努力它出來...但沒有什麼事情..所以最新?
幫助請。在C#中
謝謝.... – jjj 2012-01-10 10:59:17