2012-01-10 14 views
0

マスターページの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"> 
                    &nbsp; 
                   </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; 
} 

注:私はthisthat

を見て、仕事にしようとしたAJAXバージョン4.1.51116.0

を使用していますそれは...しかし、何も起こっていない..だから何か?

ご注意ください。

答えて

0

でそれを試す問題がAutoComplete.asmx

にあった... @Vinodと@Nehaに特別な感謝

を神に感謝

<%@ WebService Language="vb" CodeBehind="AutoComplete.asmx.vb" Class="attend.AutoComplete" %> 

Class="attend.AutoComplete" ... at

おかげで再び男..

<%@ WebService Language="vb" CodeBehind="AutoComplete.asmx.vb" Class="PMS.AutoComplete" %> 

、それが今で正常に動作している:私はAutoComplete.asmxを取り、私の

プロジェクト名はPMSであるプロジェクトが..私はそれを変更している傾向があります。 @ Vinodと@Neha

2

C#でWebサービスのコードは、ITが解決されているVB

public string[] GetCompletionList(string prefixText, int count) 
{ 
    OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\Vinu\\My Documents\\Northwind.mdb"); 
    String instr = prefixText + "%"; 
    OleDbDataAdapter da = new OleDbDataAdapter("select ContactName from Customers where ContactName like '"+instr+"'", conn); 

    DataTable dt=new DataTable(); 
    da.Fill(dt); 

    List<string> items = new List<string>(count); 
    for(int i=0;i<dt.Rows.Count;i++) 
    { 
        items.Add(dt.Rows[i].ItemArray[0].ToString()); 
    } 

    return items.ToArray(); 
} 
+0

ありがとうございました.... – jjj

関連する問題