ASP.Net UpdatePanel ImageButton 导致“this._postbackSettings.async 为 null 或不是对象”

发布于 2024-07-04 07:48:22 字数 248 浏览 6 评论 0原文

我在 dropPanelExtender 内的 popupControlExtender 内的更新面板上收到此错误。

我看到很多其他人也遇到这个问题,并进行了各种修复,但没有一个对我有用。

我很想听到一个合理的解释,解释为什么会发生这种情况,以及避免将来出现此类问题的万无一失的方法。

我发现像其他人一样,当触发器是 LinkBut​​ton 而不是 ImageButton 时,不会发生此错误,仍然想知道是否有人有解释。

I get this error on an update panel within a popupControlExtender which is within a dragPanelExtender.

I see that a lot of other people have this issue and have various fixes none of which have worked for me.

I would love to hear a logical explanation for why this is occurring and a foolproof way to avoid such issues in the future.

I have found that like others maintain this error does not occur when the trigger is a LinkButton rather than an ImageButton, still wondering if anyone has an explanation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尛丟丟 2024-07-11 07:48:22

在 ScriptManager 控件上将“EnablePartialRendering”设置为 false 可以防止出现错误,但这不是最佳解决方案。 失去部分渲染的好处可能是一件大事,具体取决于您的应用程序。

郑重声明一下,我的做法与其他看到该错误的人的做法并不完全相同。 我有一个 PopupControlExtender,其中有一个复选框列表。 我添加了一个带有 JavaScript 方法的“全选”链接,以编程方式选择/取消全选。 我没有使用图像按钮。 在添加 javascript 之前我没有看到错误,现在即使删除它之后错误仍然存​​在。 我还缺少另一个改变。

我希望这对某人有帮助......--

马特

Settign "EnablePartialRendering" to false on the ScriptManager control prevents the error, but it is not an optimal solution. Losing the benefit of partial rendering could be a big deal, depending on your application.

Just for the record, I wasn't doing exactly the same as other folks who saw the error. I have a PopupControlExtender, in which is a checkboxlist. I added a "select all" link with a javascript method to programmatically select/deselect all. I'm not using an Imagebutton. I didn't see the error before adding the javascript and now even after removing it the error remains. There has to be another change I'm missing.

I hope this helps someone...

--Matt

十二 2024-07-11 07:48:22

我最好的猜测是 UpdatePanel 无法正确地将自定义“异步”属性写入回发请求。 这可能是由于包装它的控件之一被阻止(我的直觉是它是 popupControlExtender - 它往往对 updatepanels 有奇怪的行为,因为它旨在管理其中的事件以用于显示/隐藏目的)。

我建议删除 updatepanel 并根据您的特定业务需求滚动您自己的解决方案,或者实现您自己的弹出脚本(可能更容易编写)。

顺便说一句,对于某些背景,“this._postbackSettings.async”是您的 AJAX.NET 框架试图确定这是否是异步调用。 您可以通过在发送回发之前以编程方式设置此设置来克服这个问题(捕获回发事件并将该字段添加到回发请求中(如果该字段尚不存在))。

只是一些想法......我不相信这个问题有一个“即插即用”的答案!

My best guess is that the UpdatePanel is not able to write out the custom "async" property to the postback request properly. This is likely due to blocking from one of the controls wrapping it (my gut feeling is that it's the popupControlExtender - it tends to have odd behavior with updatepanels, as it is intended to manage the events inside it for it's show/hide purposes).

I would recommend either removing the updatepanel and rolling your own solution for your specific business need for having it there, or implementing your own popup script (probably slightly easier to write).

Incidentally, for some background, the "this._postbackSettings.async" is your AJAX.NET framework trying to figure out whether this is an async call or not. You might be able to overcome it by setting this programaticly before the postback is sent (catch the postback event and add the field to the postback request if it is not already there).

Just some thoughts...I do not believe there is a "plug and play" answer for this one!

终弃我 2024-07-11 07:48:22

我遇到了同样的问题,并且没有真正找到任何令人满意的解决方案,直到我最终得到 https://siderite.dev/blog/thispostbacksettingsasync-is-null-or.html 这正是我想要的。

为了避免将来可能出现死链接的问题,这里是代码:

var script = @"
if (Sys &&
    Sys.WebForms && Sys.WebForms.PageRequestManager &&
    Sys.WebForms.PageRequestManager.getInstance) 
{
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm &&
       !prm._postBackSettings)
    {
        prm._postBackSettings = prm._createPostBackSettings(false, null, null);
    }";

ScriptManager.RegisterOnSubmitStatement(
    Page, 
    Page.GetType(), 
    "FixPopupFormSubmit", 
    script);

如果在没有设置 _postBackSettings 的情况下提交,它会创建它们,导致空引用异常消失,因为 _postBackSettings.async 可用。

希望这有帮助,

G.

I've had the same problem and haven't really found any satisfying solution until I ended up on https://siderite.dev/blog/thispostbacksettingsasync-is-null-or.html which does exactly what I want.

Just to avoid problems with possible dead links in the future here is the code:

var script = @"
if (Sys &&
    Sys.WebForms && Sys.WebForms.PageRequestManager &&
    Sys.WebForms.PageRequestManager.getInstance) 
{
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm &&
       !prm._postBackSettings)
    {
        prm._postBackSettings = prm._createPostBackSettings(false, null, null);
    }";

ScriptManager.RegisterOnSubmitStatement(
    Page, 
    Page.GetType(), 
    "FixPopupFormSubmit", 
    script);

In case of a submit without the _postBackSettings being set it creates them, causing the null reference exception to disappear as _postBackSettings.async is then available.

Hope this helps,

G.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文