asp.net AutoComplete Control

作者:袖梨 2022-06-25

asp教程.net autocomplete control

assembly="ajaxcontroltoolkit" %>

"">

protected void btnsubmit_click(object sender, eventargs e)
{
lblselectedproducttitle.text = txtproducttitle.text;
}

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


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">


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" />




相关文章

精彩推荐