sender._postBackSettings.sourceElement 未定义
这就是我想要做的 -
当文档准备好时使用 jQuery,如果页面没有回发,我会为 updatepanel 发出手动回发以从数据库检索数据。
当更新面板获取数据时,我会显示一个更新进度,当特定更新面板完成时我会隐藏该更新进度。我还想“阻止”屏幕进行任何交互。加载数据后,表单上有其他按钮,我想阻止所有内容,以防出现任何部分回发。
这是代码:
$(document).ready(function ()
{
if(<% =(Not Page.isPostBack).ToString().ToLower() %>)
{
__doPostBack('upShipping');
}
}
function pageLoad() {
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
}
function BeginRequestHandler(sender, args)
{
$('.blur').css("display", "block");
if (args._postBackElement.id == 'upShipping') {
$get('divCalculating').className = 'Show';
}
}
function EndRequestHandler(sender, args)
{
$('.blur').css("display", "none");
if (sender._postBackSettings.sourceElement.id == 'upShipping')
{
$get('divCalculating').className = 'Hidden';
}
}
如果我不在屏幕上“单击”,一切都会很好。但是,如果我在 updatepanel 更新时单击屏幕上的任意位置,则“EndRequestHandler”不会触发,并且我会陷入加载 gif 并阻塞屏幕的状态。 我在浏览器的错误控制台中收到以下错误: sender._postBackSettings.sourceElement 未定义 有
什么想法吗?
谢谢!
缺口
This is what I'm trying to do -
Using jQuery when the document is ready and if the page is not postback I issue a manual postback for an updatepanel to retrieve data from a database.
While the updatepanel is getting the data I present an updateprogress which I hide when the specific updatepanel finishes. I also want to "BLOCK" the screen from any interaction. After the data is loaded I have additional buttons on the form and I want to block everything in case of any partial-postback.
Here is the code:
$(document).ready(function ()
{
if(<% =(Not Page.isPostBack).ToString().ToLower() %>)
{
__doPostBack('upShipping');
}
}
function pageLoad() {
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
}
function BeginRequestHandler(sender, args)
{
$('.blur').css("display", "block");
if (args._postBackElement.id == 'upShipping') {
$get('divCalculating').className = 'Show';
}
}
function EndRequestHandler(sender, args)
{
$('.blur').css("display", "none");
if (sender._postBackSettings.sourceElement.id == 'upShipping')
{
$get('divCalculating').className = 'Hidden';
}
}
If I do not "CLICK" on the screen everything works great. But if I just click anywhere on the screen while the updatepanel updates the "EndRequestHandler" doesn't fire and I'm stuck with the loading gif and blocked screen.
I get the following error in the error console of the browser: sender._postBackSettings.sourceElement is undefined
Any ideas?
Thanks!
Nick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于某种原因,
sender._postBackSettings.sourceElement
在EndRequestHandler
中不断返回 NULL。我定义了一个全局变量,在
BeginRequestHandler
中为它分配了一个值,并在EndRequestHandler
中检查了它的值。这解决了问题。
For some reason
sender._postBackSettings.sourceElement
kept coming back as NULL in theEndRequestHandler
.I defined a global var, assigned it a value at the
BeginRequestHandler
and checked its value instead in theEndRequestHandler
.This solved the problem.