------------------------ASPX PAGE--------------------------------
var AutoTestID = 0;
$(document).ready(function(){
$("#txtTestName").autocomplete({
source: function (request, response) {
TestID= 0;
$.ajax({
url: "ReferalIntakeOrg.aspx/GetPatientNameAutoSugg",
data: "{ 'TestName': '" + request.term + "','PhoneNo':'"+ $("#txtPrimaryNo").val()+"'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.Name,
value: item.Name,
Id: item.Id
}
}))
}
});
},
minLength: 1,
select: function (event, ui) {
AutoTestID= ui.item.Id;
FillTestDetails(AutoTestID);
}
});
}); //document.ready ends here
--------------ASPX.CS PAGE----------------
[WebMethod]
public static List<AutoFillItem> GetPatientNameAutoSugg(string PatientName, string PrimaryContactNo)
{
List<AutoFillItem> list = new List<AutoFillItem>();
ServiceReference1.TestWCFServiceClient oITestWCFService = new ServiceReference1.TestWCFServiceClient();
DataSet ds = oITestWCFService.GetTestNameAutoSugg(TestName, PhoneNo);
foreach (DataRow tr in ds.Tables[0].Rows)
{
AutoFillItem item = new AutoFillItem();
item.Id = tr[0].ToString();
item.Name = tr[1].ToString();
list.Add(item);
}
return list.ToList();
}
------------------------ADD A CLASS AutoFillItem.cs------------------
//declare our needs
public string Id;
public string Name;
var AutoTestID = 0;
$(document).ready(function(){
$("#txtTestName").autocomplete({
source: function (request, response) {
TestID= 0;
$.ajax({
url: "ReferalIntakeOrg.aspx/GetPatientNameAutoSugg",
data: "{ 'TestName': '" + request.term + "','PhoneNo':'"+ $("#txtPrimaryNo").val()+"'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) { return data; },
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.Name,
value: item.Name,
Id: item.Id
}
}))
}
});
},
minLength: 1,
select: function (event, ui) {
AutoTestID= ui.item.Id;
FillTestDetails(AutoTestID);
}
});
}); //document.ready ends here
--------------ASPX.CS PAGE----------------
[WebMethod]
public static List<AutoFillItem> GetPatientNameAutoSugg(string PatientName, string PrimaryContactNo)
{
List<AutoFillItem> list = new List<AutoFillItem>();
ServiceReference1.TestWCFServiceClient oITestWCFService = new ServiceReference1.TestWCFServiceClient();
DataSet ds = oITestWCFService.GetTestNameAutoSugg(TestName, PhoneNo);
foreach (DataRow tr in ds.Tables[0].Rows)
{
AutoFillItem item = new AutoFillItem();
item.Id = tr[0].ToString();
item.Name = tr[1].ToString();
list.Add(item);
}
return list.ToList();
}
------------------------ADD A CLASS AutoFillItem.cs------------------
//declare our needs
public string Id;
public string Name;
No comments:
Post a Comment