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">
方法二
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">