我有两个下拉列表("#MainContent_Alerts_Grid1_ddlCaseTypeNew","#MainContent_Alerts_Grid1_ddlCaseNew")
我正在使用ajax填充"#MainContent_Alerts_Grid1_ddlCaseNew"
<asp:DropDownList Width="95%" ID="ddlCaseNew"
runat="server" DataValueField="Id" />
关于改变&#34;#MainContent_Alerts_Grid1_ddlCaseTypeNew&#34;
<asp:DropDownList Width="95%" ID="ddlCaseTypeNew"
runat="server" DataValueField="Id" OnSelectedIndexChanged="ddlCaseTypeNew_SelectedIndexChanged">
<asp:ListItem Value="0">Select</asp:ListItem>
<asp:ListItem Value="1">C</asp:ListItem>
<asp:ListItem Value="2">D</asp:ListItem>
<asp:ListItem Value="3">P</asp:ListItem>
<asp:ListItem Value="4">T</asp:ListItem>
<asp:ListItem Value="5">I</asp:ListItem>
<asp:ListItem Value="6">R</asp:ListItem>
</asp:DropDownList>
这是我的代码
$("#MainContent_Alerts_Grid1_ddlCaseTypeNew").change(function () {
var dynamicURL = document.location.href.indexOf('AliAndAssociates');
var ddl = document.getElementById("MainContent_Alerts_Grid1_ddlCaseTypeNew");
var ParentID = ddl.options[ddl.selectedIndex].value;
dynamicURL = document.location.href.substring(0, dynamicURL) + 'AliAndAssociates/' + 'ApplicationForms/DashBoard/Dashboard.aspx/GetCases';
$.ajax({
type: "POST",
url: "" + dynamicURL + "",
data: "{'ParentID': '" + ParentID + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnCaseSuccess,
failure: function (response) {
Message = response.d;
}
});
return false;
});
function OnCaseSuccess(response) {
var jsonp = response.d;
var lang = '';
var obj = $.parseJSON(jsonp);
$("#MainContent_Alerts_Grid1_ddlCaseNew").empty();
$.each(obj, function () {
var optionhtml = '<option value="' + this['Id'] + '">' + this['Description'] + '</option>';
$("#MainContent_Alerts_Grid1_ddlCaseNew").append(optionhtml);
});
}
这是我的网络方法
static public string GetCases(string ParentID)
{
LegalFilesContext context = new LegalFilesContext();
Int64 id = Convert.ToInt64(ParentID);
DataTable dtCorr = new DataTable();
List<IntellectualPropertyCase> Cases = (from b in context.IntellectualPropertyCases
.Include("CaseMemo")
.Include("CaseMemo.Corporate")
where b.IntellectualPropertyTypeId == id select b).ToList();
dtCorr.Columns.Add("Id");
dtCorr.Columns.Add("Description");
DataRow Row = dtCorr.NewRow();
Row[0] = 0;
Row[1] = "Please Select";
dtCorr.Rows.Add(Row);
for (int a = 0; a < Cases.Count; a++)
{
if (Cases[a].CaseMemo.Corporate.Description != null)
{
DataRow newRow = dtCorr.NewRow();
if (Cases[a].Id == 0)
newRow[0] = 0;
else
newRow[0] = Cases[a].Id;
newRow[1] = Cases[a].CaseMemo.Corporate.Description;
dtCorr.Rows.Add(newRow);
}
}
string JSONChild = JsonConvert.SerializeObject(dtCorr);
return JSONChild;
}
代码在我的计算机上正常工作,但在部署后无法正常工作。