一聚教程网:一个值得你收藏的教程网站

热门教程

asp.net AutoComplete Control

时间:2022-06-25 04:14:59 编辑:袖梨 来源:一聚教程网

asp教程.net  autocomplete control
<%@ page language="c#" %>
<%@ register tagprefix="ajax" namespace="ajaxcontroltoolkit"
 assembly="ajaxcontroltoolkit" %>
<%@ import namespace="system.linq" %>
 "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">

http://www.w3.org/1999/xhtml">

    autocomplete page method


   


   

   
            id="lblproducttitle"
        text="product:"
        associatedcontrolid="txtproducttitle"
        runat="server" />
            id="txtproducttitle"
        autocomplete="off"
        runat="server" />
            id="ace1"
        targetcontrolid="txtproducttitle"
        servicemethod="getsuggestions"
        minimumprefixlength="1"
        runat="server" />
            id="btnsubmit"
        text="submit"
        onclick="btnsubmit_click"
        runat="server" />

   

            id="lblselectedproducttitle"
        runat="server" />

   


   


方法二

file: fileservice.asmx

<%@ webservice language="c#" class="fileservice" %>
using system;
using system.web;
using system.web.services;
using system.web.services.protocols;
using system.io;
using system.linq;

[webservice(namespace = "http://tempuri.org/")]
[webservicebinding(conformsto = wsiprofiles.basicprofile1_1)]
[system.web.script.services.scriptservice]
public class fileservice  : system.web.services.webservice {

    [webmethod]
    public string[] getsuggestions(string prefixtext, int count)
    {
        directoryinfo dir = new directoryinfo("c:windows");
        return dir
            .getfiles()
            .where( f => f.name.startswith(prefixtext) )
            .select( f => f.name )
            .toarray();
     }
}

           
file: autocompletewebservice.aspx

<%@ page language="c#" %>
<%@ register tagprefix="ajax" namespace="ajaxcontroltoolkit"
 assembly="ajaxcontroltoolkit" %>
 "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">

http://www.w3.org/1999/xhtml">

    show autocomplete web service


   


   

   

            id="lblfilename"
        text="file name:"
        associatedcontrolid="txtfilename"
        runat="server" />
            id="txtfilename"
        autocomplete="off"
        runat="server" />
            id="ace1"
        targetcontrolid="txtfilename"
        servicemethod="getsuggestions"
        servicepath="~/fileservice.asmx"
        minimumprefixlength="1"
        runat="server" />
            id="btnsubmit"
        text="submit"
        onclick="btnsubmit_click"
        runat="server"/>

   

            id="lblselectedfilename"
        runat="server" />
   


   


热门栏目