ASP. NET MVC build Project Background UI Framework-1, background main frame
Requirements: In the query record, enter the first word, automatically the word begins with the relevant records to find out, enter 2 words to filter the records beginning with the two children, and so on.
Suddenly to use this function, the impression has written this feature of the article, all of a sudden can not find, had to re-posted out of the memo. Recently the blog has not been updated for nearly 2 months, because these two months have been writing books behind closed doors.
Introduction of JS and css:http://download.csdn.net/detail/zouyujie1127/9550279
<link href= "~/libs/autocomplete/css/ui-lightness/jquery-ui-1.8.17.custom.css" rel= "stylesheet"/>
<script src= "~/libs/autocomplete/js/jquery-ui-1.8.17.custom.min.js" ></script>
Add the following JS code to the View interface:
<script type= "Text/javascript" >
$ (function () {
Getcustomerlist ("Cusname");});
//Automatically load customer listfunctionGetcustomerlist (TXT) {if (txt = = Undefined | | txt = = "")Return; $("#"+TXT). AutoComplete ({source: "/customer/getcusnamelist", minlength:1});//$ ("#" + txt). focus (function () {// if ($ (this). val () = = "Please enter username") {// $ (this). CSS ("Color", "Black"). Val (""); // //////cursor left //// $ (this). CSS ("Color", "Gray"). Val ("Please enter user name"); // //});}
</script>
The list method in Customercontroller is as follows:
/// <summary> ///get the Customer list fuzzy query/// </summary> /// <param name= "term" ></param> /// <returns></returns> Public stringGetcusnamelist (stringTerm ) { if(string. Isnullorwhitespace (term))return NULL; varDataSource = Customerinfo.getbyfilter (Newcustomerfilter {cusname =Term }); List<string> list = Datasource.select (x=>x.cusname). ToList (); //Serializing ObjectsSystem.Web.Script.Serialization.JavaScriptSerializer js =NewSystem.Web.Script.Serialization.JavaScriptSerializer (); returnJS. Serialize (list. ToArray ()); }
ASP. NET MVC build Project Background UI Framework-11, Auto load dropdown box query