为了摆脱这种不必要的.axd文件,使用了来自Microsoft的Ajax.dll,并为其编写了自己的代码。使用Ajax的例子如下。
假设我使用按钮单击多个删除功能,我不想使用更新面板由于页面加载尝试这一点。
using Ajax;
注册您的页面加载事件 的Page_Load
Ajax.Utility.RegisterTypeForAjax(typeof(Admin_UserControls_Delete));
方法
[Ajax.AjaxMethod()]
public int deleteRecords(int ID,string spName)
{
// delete code block
}
> In your **markup source on client click of button** call the javascript.
function callbackmethod(response) {
if (response.value > 0) {
alert("Record deleted Successfully");
window.location.reload();
}
else {
alert("Can Not Delete Record,It is being Used");
}
}
function DeleteMultipleRecords() {
//delete block to get the param values
var str = Admin_UserControls_Delete.deleteRecords(param1,param2,callbackmethod);
}
使用ScriptManager增加所需的UpdatePanel的微软的Ajax参考对照。 –
雅这很好,但我需要多个文件,我有4个文件加载和由于其中的页面加载时间增加 – Murtaza
是的,但它们是轻量级的。国际海事组织,以提高您的应用程序性能使用Microsoft CDN(将EnableCdn属性设置为true)。 –