爲了擺脫這種不必要的.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)。 –