asp教程.net autocomplete control
assembly="ajaxcontroltoolkit" %>
"">
protected void btnsubmit_click(object sender, eventargs e)
{
lblselectedproducttitle.text = txtproducttitle.text;
}
http://www.***w3.org/1999/xhtml">
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
using system;
using system.web;
using system.web.services;
using system.web.services.protocols;
using system.io;
using system.linq;
[webservice(namespace = "")]
[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
assembly="ajaxcontroltoolkit" %>
"">
http://www.***w3.org/1999/xhtml">
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" />