当我使用jquery multiselect close函数时,我在方法后面的代码中调用webmethod是没有命中的 我的剧本是:
$(document).ready(function () {
$('.department').multiselect({
show: ["bounce", 5], hide: ["blind", 1],
close: function () {
debugger;
var values = new Array();
$(this).multiselect("getChecked").each(function (index, item) {
values.push($(item).val());
});
$("input[id*=selectedValues]").val(values.join(","));
document.getElementById("<%=hdnDepartment.ClientID %>").value = values;
if (document.getElementById("<%=hdnDepartment.ClientID %>").value != "") {
//$("#<%=Button1.ClientID %>")[0].click();
$.ajax({
type: "POST",
url: "wfrmLeave_PermisssionReport.aspx/Populate",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
}
});
}
}
})
.multiselectfilter();
});
我的方法是:
[System.Web.Services.WebMethod]
public void Populate()
{
strQuery = "select * from tblhrims_employeedetail where nvrresigned='No'";
if (ddlBusinessUnit.SelectedItem.ToString() != "Select")
{
strQuery += "and nvrbusinessunit ='" + ddlBusinessUnit.SelectedValue + "' ";
}
if (hdnDepartment.Value != "")
{
string strDepartment = hdnDepartment.Value;
string[] strarrDepartment = strDepartment.Split(',');
strDepartment = "";
for (int i = 0; i < strarrDepartment.Length; i++)
{
strDepartment += "'" + strarrDepartment[i] + "'" + ",";
}
strDepartment = strDepartment.TrimEnd(',');
strQuery += "and nvrdepartment in(" + strDepartment + ")";
}
populateDropDown(strQuery, ddlEmployeeName, "nvrempname", "nvrempcode");
}