You can have a page method which will get the values from database and return in JSON formatted string. You can also use asmx web methods to return the same result.
$('#ddlName').change(function () {
PopulatePersonDetail($('#ddlName').val());
});
Call the method using jQuery 'ajax' method and get the JSON object which contains the actual values.
function PopulatePersonDetail(){
var name = 'smruti';
$.ajax({
type: "POST",
url: "../WebMethods/WebService.asmx/GetPersonDetailsByName",
data: "{key:'" + name + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (response) {
$.each(JSON.parse(response.d), function (key, value) {
var result = $.parseJSON(response.d);
$('#txtAge').val(result.Age);
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
ShowError(failMessage, 450, 100);
}
});
}
Here is the web method which is called to get data.
[WebMethod(EnableSession = true)]
public string GetPersonDetailsByName(string name)
{
string jsonData = string.Empty;
Person personData = new Person();
List<Person> PersonEntityList = personData.GetPersonDetailsByName(string name);
jsonData = Parser.EntityToJSon(PersonEntityList);
return jsonData;
}
Hope this will definitely be helpful.