我已经在代码下面的webMethods页ASP.net两个因pagemethods
[WebMethod]
[ScriptMethod]
public static string BindDataTable()
{
//This function connects to db gets the result and binds a datatable
}
[WebMethod(EnableSession = true)]
[ScriptMethod]
public static string DeleteItems(int[] ids)
{
//This function deletes the items
}
后面在aspx页面我有一个元件被同时触发页面方法
<a href="#" onclick="Delete()"> Delete</a>
和Delete(删除) js的功能如下
function Delete(){
PageMethods.DeleteItems(selectedIds);
PageMethods.BindDataTable();
}
检查控制台在萤火虫显示,这两个Pageme thods被触发 先后
- DeleteItems
- BindDataTable
但是,有时BindDataTable被删除功能完成承诺其保持在表中从没有刷新在视觉上更新数据库之前开始。
任何想法如何触发调用一个pagemethod只是在前一页pagemethod完成它的服务器端命令后? 感谢
我打过电话的RegisterStartupScript方法从JS调用的绑定PageMethod的C#的DeleteItems功能结束。由于WebMethod是静态的,因此无法在此处使用RegisterStartupScript函数的大部分参数。 –