Autocomplete combobox using webservice and entityFramework


This creates a autocomplete type of combobox.It fills the combo from database using web service and data fetch is done using entity framework. It would display the student names in a combobox. u can search the name in combobox also , it will show related matches.

The status of this resource is Pending and require some modification by the author.





<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://5bd43a8b85d977468b795ebb1cefd89e46ea7adb.googledrive.com/host/0B8sSQit1nMHNQUxrVnpfNWRXcUE/technologymantracombo.js"></script>
<script type="text/javascript">
function fill() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService2.asmx/getStudents",
data: '{}',
dataType: "json",
success: function (Result) {
var jsdata = JSON.parse(Result.d);
// alert(jsdata);
// var jsdata = Result.d;
$.each(jsdata, function (key, value) {
$('#MySelect').append($("").val(value.id).html(value.name));
});
$("#MySelect").combify(); // this method converts drop down to combo-box and enables auto search
},
error: function (Result) {
alert("Error");
}
});
}
<script/>


My Auto complete combobox :


<script type="text/javascript">
$(document).ready(function () {
fill();
});
<script/>



web service method, is uses entity framework to get list of studentnames from DB and return a Json serialzed string:

[WebMethod]
public string getStudents()
{
CoreEntities _Contex = new CoreEntities();
var list = (from m in _Contex.tblStudentInfoes where m.int_Status == 1 select new { id = m.int_Student_Id, name = m.str_Last_Name }).ToList();
return (new JavaScriptSerializer().Serialize(list));
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: