简体   繁体   English

sender._postBackSettings.sourceElement未定义

[英]sender._postBackSettings.sourceElement is undefined

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. 当文档准备好并且页面没有回发时使用jQuery,我为updatepanel发出了手动回发,以便从数据库中检索数据。

While the updatepanel is getting the data I present an updateprogress which I hide when the specific updatepanel finishes. 当updatepanel获取数据时,我会显示一个updateprogress,当特定的updatepanel完成时,我将其隐藏。 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. 但是,如果我在updatepanel更新时仅单击屏幕上的任意位置,则不会触发“ EndRequestHandler”,并且会卡住加载的gif和受阻的屏幕。 I get the following error in the error console of the browser: sender._postBackSettings.sourceElement is undefined 我在浏览器的错误控制台中收到以下错误:sender._postBackSettings.sourceElement未定义

Any ideas? 有任何想法吗?

Thanks! 谢谢!

Nick 缺口

For some reason sender._postBackSettings.sourceElement kept coming back as NULL in the EndRequestHandler . 由于某种原因, sender._postBackSettings.sourceElementEndRequestHandler始终以NULL的形式返回。

I defined a global var, assigned it a value at the BeginRequestHandler and checked its value instead in the EndRequestHandler . 我定义了一个全局变量,在BeginRequestHandler为其分配了一个值,并在EndRequestHandler检查了它的值。
This solved the problem. 这样就解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM