Server Side Code
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetBindBudgetlineresult(string ID)
{
TCA_OSOEntities context = new TCA_OSOEntities();
var PID = Convert.ToInt32(ID);
var Budgetlineresult = (from MstrBudgetLine tbl in context.MstrBudgetLines
where tbl.IsDeleted == 0 && tbl.IsActive == 1 && tbl.ParenetID == PID
select new
{
BudgetLinesPkID=tbl.BudgetLinesPkID,
BudgetLinesName=tbl.BudgetLinesName
}).ToList();
var jsonSerialiser = new JavaScriptSerializer();
var jsonresult = jsonSerialiser.Serialize(Budgetlineresult);
return jsonresult;
}
Client Side Code
function ddlparentexpensetype_SelectedIndexChanged(sender, args) {
// To get the item
var item = args.get_item();
//To get the item text
var itemText = args.get_item()._text;
BindBudgetline();
}
***********************************************
function BindBudgetline() {
$.ajax({
type: "POST",
url: "AddInitiative.aspx/GetBindBudgetlineresult",
data: '{ID: "' + document.getElementById("<%= ddlparentexpensetype.ClientID %>").control._value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnBudgetlineSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnBudgetlineSuccess(response) {
var data = JSON.parse(response.d);
if (data.length != 0) {
var drop = $find('<%=dropdownbudgetline.ClientID %>');
drop.clearItems();
drop.set_text("");
for (var i = 0; i < data.length; i++) {
var combo = $find("<%= dropdownbudgetline.ClientID %>");
var comboItem = new Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text(data[i]["BudgetLinesName"]);
combo.set_value(data[i]["BudgetLinesPkID"]);
combo.trackChanges();
combo.get_items().add(comboItem);
comboItem.select();
combo.commitChanges();
}
}
else {
var drop = $find('<%=dropdownbudgetline.ClientID %>');
drop.clearItems();
drop.set_text("");
}
}
/* End*/
function AmountConvertions() {
$.ajax({
type: "POST",
url: "AddInitiative.aspx/GetConvertedAmount",
data: "{ 'Amt': '" + document.getElementById("<%= txtrequestedbudgetbyoso.ClientID %>").value + "', 'Osoid': '" + document.getElementById("<%= dropdownoso.ClientID %>").control._value + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnAmountConvertionsSuccess,
failure: function (response) {
alert(response.d);
}
});
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetBindBudgetlineresult(string ID)
{
TCA_OSOEntities context = new TCA_OSOEntities();
var PID = Convert.ToInt32(ID);
var Budgetlineresult = (from MstrBudgetLine tbl in context.MstrBudgetLines
where tbl.IsDeleted == 0 && tbl.IsActive == 1 && tbl.ParenetID == PID
select new
{
BudgetLinesPkID=tbl.BudgetLinesPkID,
BudgetLinesName=tbl.BudgetLinesName
}).ToList();
var jsonSerialiser = new JavaScriptSerializer();
var jsonresult = jsonSerialiser.Serialize(Budgetlineresult);
return jsonresult;
}
Client Side Code
function ddlparentexpensetype_SelectedIndexChanged(sender, args) {
// To get the item
var item = args.get_item();
//To get the item text
var itemText = args.get_item()._text;
BindBudgetline();
}
***********************************************
function BindBudgetline() {
$.ajax({
type: "POST",
url: "AddInitiative.aspx/GetBindBudgetlineresult",
data: '{ID: "' + document.getElementById("<%= ddlparentexpensetype.ClientID %>").control._value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnBudgetlineSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnBudgetlineSuccess(response) {
var data = JSON.parse(response.d);
if (data.length != 0) {
var drop = $find('<%=dropdownbudgetline.ClientID %>');
drop.clearItems();
drop.set_text("");
for (var i = 0; i < data.length; i++) {
var combo = $find("<%= dropdownbudgetline.ClientID %>");
var comboItem = new Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text(data[i]["BudgetLinesName"]);
combo.set_value(data[i]["BudgetLinesPkID"]);
combo.trackChanges();
combo.get_items().add(comboItem);
comboItem.select();
combo.commitChanges();
}
}
else {
var drop = $find('<%=dropdownbudgetline.ClientID %>');
drop.clearItems();
drop.set_text("");
}
}
/* End*/
function AmountConvertions() {
$.ajax({
type: "POST",
url: "AddInitiative.aspx/GetConvertedAmount",
data: "{ 'Amt': '" + document.getElementById("<%= txtrequestedbudgetbyoso.ClientID %>").value + "', 'Osoid': '" + document.getElementById("<%= dropdownoso.ClientID %>").control._value + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnAmountConvertionsSuccess,
failure: function (response) {
alert(response.d);
}
});
}