//删除
function btnDel_onclick() {
PageMethods.DelDepartment(id,CallBackFunction);
}
//回调函数
function CallBackFunction(result){
alert(result);
}
/// <summary>
/// 删除部门信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[WebMethod]
public static string DelDepartment(int id)
{
Department obj = new Department();
obj.Id = id;
try
{
int result = DepartmentManager.DeleteDepartment(obj);
if (result == 1)
{
return "删除成功!";
}
else
return "请单击行,选择数据!!!";
}
catch (Exception)
{
return "此部门信息已经存盘(和其它业务发生往来),不能删除!";
}
}应该怎么及时让他刷新?
function btnDel_onclick() {
PageMethods.DelDepartment(id,CallBackFunction);
}
//回调函数
function CallBackFunction(result){
alert(result);
}
/// <summary>
/// 删除部门信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[WebMethod]
public static string DelDepartment(int id)
{
Department obj = new Department();
obj.Id = id;
try
{
int result = DepartmentManager.DeleteDepartment(obj);
if (result == 1)
{
return "删除成功!";
}
else
return "请单击行,选择数据!!!";
}
catch (Exception)
{
return "此部门信息已经存盘(和其它业务发生往来),不能删除!";
}
}应该怎么及时让他刷新?
if (result == 1)
{
bind();
return "删除成功!";
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Databind();
}
} /// <summary>
/// 显示部门信息
/// </summary>
private void Databind()
{
IList<Department> list = DepartmentManager.GetAllDepartments();
if (list == null)
{ }
else
{
repDepartment.DataSource = list;
repDepartment.DataBind();
}
}
page.Databind(); 返回之前加这个,不但不能刷新,反而返回值JS的回调函数接受不到
document.forms[0].submit();
window.document.location=window.document.location.href;