function TestFunction(ddlType){
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../Script Services/AutoComplete.asmx/SampleWebMethod",
datatype: "JSON",
parameters: { param1: ddlType },
data: "{intTypeID: " + intTypeID + "}",
success: function (response) {
TestFunctionOnSuccess(ddlType, response.d);
}
});}
[WebMethod(EnableSession = true)]
[System.Web.Script.Services.ScriptMethod]
public SampleObject[] SampleWebMethod(int? intTypeID)
{
DataTable dt = new DataTable();
dt = ProjectBusinessLayer.Type.TypeSelect(intTypeID.Value);
List<SampleObject> Details = new List<SampleObject>();
foreach (DataRow dtrow in dt.Rows)
{
string TestID = dtrow["TestID"].ToString();
string TestValue = dtrow["TestValue"].ToString();
Details.Add(new SampleObject(TestID, TestValue));
}
return Details.ToArray();
}
function TestFunctionOnSuccess(ddlType, lstTestDetails) {
// Do the functionality you need
}
No comments:
Post a Comment