AutoComplete example composed of jquery + Asp.net + WebService

Source: Internet
Author: User

Rough version:

 

Code

Function reload () {SYS. webforms. pagerequestmanager. getinstance (). add_endrequest (initpage );}
Function initpage (){
VaR JSON = getjson ();
VaR DATA = eval ('+ JSON + ')');
$ ('# <% = Txtaudit. clientid %>'). AutoComplete (data ,{
Width: 150,
MAX: 50,
Minchars: 1,
Cachelength: 20,
Delay: 150,
Matchcontains: True,
AutoFill: false,
Scrollheight: 300,
Formatitem: function (row, I, max ){
Return row. Name;
},
// Formatmatch: function (row, I, max ){
// Var TXT =. Val ();
// Return itemcheck (row, txt );
//},
Formatresult: function (ROW ){
Return row. employeename;
}
}). Result (function (event, item ){
VaR auditid =$ ('# <% = hauditid. clientid %> ');
Auditid. Val (item. ID );
});
Data = NULL;
}
Function getjson (){
VaR res;
$. Ajax ({
Async: false,
Type: "Post", // WebService access request using post
Contenttype: "application/JSON", // WebService returns the JSON type
URL: "../WebService. asmx/getemployeelist", // address and method name combination of WebService call ---- wsurl/method name
Data: "{}", // here is the parameter to be passed, in the format of data: "{paraname: paravalue}", as shown below
Datatype: 'json ',
Success: function (result ){
Res = result. D;
},
Error: function (result, status) {// if no above capture error occurs, the callback function here will be executed
If (status = 'error '){
Alert ("error:" + result );
}
}
});
Return res;
}
$ (). Ready (function (){
Reload ();
Initpage ();
});

A new version will be created after the upgrade.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.