views:

519

answers:

2

I am calling this in the code-behind of a page loaded into a Shadowbox popup:

        ScriptManager.RegisterStartupScript(this, this.GetType(),
           "CloseScript", "parent.closeServiceOption();", true);

I know that the Javascript function is being called, since get the Alert() box pops up, and I can step through the code in the IE Developer Toolbar.

        function closeServiceOption() {
          Shadowbox.close();
          alert("updating");
          __doPostBack('<% =upGrid.ClientID %>', '');
        return true;

upGrid is an asp:UpdatePanel on the parent page:

       <asp:UpdatePanel ID="upGrid" runat="server" UpdateMode="Conditional" 
       EnableViewState="true">

This trick works on several other pages, but not on the one that I just wrote, and I can't figure out why.

This is the error that IE shows me:

  Object doesn't support this property or method  ScriptResource.axd?
  d=mnUf4WG8LrLFogIwzhvkGVdo-KPzLIFFBfGx6AcICRfPeY_Du0eoxLRaVGrqyoAqxR8l67
  1VS6MZAdxdawuxsyoM3wpGxwL83KwO7UehZus1&t=ffffffffec2d9970,
  line 4723 character 21

Line 4723 is the finally() clause in the Sys$Net$XMLHttpExecutor function:

  finally {
      if (_this._xmlHttpRequest != null) {
          _this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
          _this._xmlHttpRequest = null;
       }
  }

2 lines later I get "Permission denied", and "Access is denied" for all other properties of xmlHttpRequest when I inspect them in the debugger. Again, I use this trick (calling __doPostBack on the client) on several other pages where it works. The UpdatePanel has the same attributes (specifically, ViewState is enabled, and disabling it does not fix the issue), and I don't see anything else that is different on this page, but there must be something I am missing. Any ideas?

Firefox/Firebug, btw, does not show any errors at all but the UpdatePanel does not post back, either.

A: 

Rather than manually triggering __doPostBack, I'd call the Update method on your UpdatePanel.

function closeServiceOption() {
    Shadowbox.close();
    alert("updating");
    var upGrid = document.getElementById("upGrid");
    upGrid.update();
    return true;
}
Aaron Daniels
Are you sure that there is an update() method? I use the AjaxToolkit, but no custom extensions like this one http://daron.yondem.com/CommentView.aspx?guid=52b9bf2e-bf76-439d-8a5f-e9b1c70ce9e2
cdonner
It's not a custom extension. It's part of the UpdatePanel itself. I've used it before, and I just created a sample project that used it successfully.
Aaron Daniels
A: 

Microsoft should consider and resolve these Issue.

UpdatePanel uses Partial Rendering. try UpdateMode="Conditional" ChildrenAsTriggers="true">

Control doesnt maintain its state It needs to RegisterClient Side.

2nd. Dim cs As ClientScriptManager = Page.ClientScript cs.RegisterClientScriptBlock(Me.GetType(), ControlNAme.ClientID, "" & vbCr & vbLf & "window.ControlNAme='" + ControlNAme.ClientID + "';" & vbCr & vbLf & "")

3rd. Try using ICallbackEventHandler Interface to avoid postback which cause to loose the state of the control and Javascript start bugging you.

Chao.

DBMaster