如何检测ASP.Net异步PostBack及其设置,如控件和UpdatePanel导致PostBack和使用JavaScript中的PageRequestManager事件,这里是我正在做的一个例子:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "Button1" EventName = "Click" />
</Triggers>
</asp:UpdatePanel>
</form>
//////////////
//一些javascript代码
/////////////
</body>
</html>
我想要的是使用java脚本来检测此帖子
答案 0 :(得分:0)
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
prm.add_beginRequest(function (sender, e) {
//Event raised when the Async Postback is started.
//Detect whether the request is Async
var isAsync = sender._postBackSettings.async;
//Detect Id of the control that caused the postback.
var controlId = sender._postBackSettings.sourceElement.id;
//Id of the updatepanel that caused the postback
var updatePanelId = sender._postBackSettings.panelID.split('|')[0];
});
}
prm.add_endRequest(function (sender, e) {
if (sender._postBackSettings.panelsToUpdate != null) {
//Event Raised when the Async Postback is completed.
}
});
把这个并告诉我结果:)你知道同一篇文章在这个链接中发布了相同的代码: http://www.aspsnippets.com/
如果你不明白要求解释:)