3

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.

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

it's been a really long time since I last had to deal with this issue as I don't use Microsoft Ajax anymore, but this looks like a nice clean solution.
1

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!

1 Comment

I ended up using a LinkButton with an Image which I found to be the simplest solution, although what you suggest is probably more reliable in general.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.