0

I have problem using the Response object inside the updatepanel

<asp:UpdatePanel ID="UP_ExportPrompt" runat="server" UpdateMode="Always">
                <ContentTemplate>
                    <div>
                        <ul>
                            <li>
                                <label class="f450">
                                    <asp:Literal runat="server" Text="<%$ Resx : Reports_ExportOnlyPrompt %>" />
                                </label>
                            </li>
                            <li>
                                <label class="f80">
                                    <asp:Label runat="server" Text="<%$ Resx : FileFormatColon %>" />
                                </label>
                                <asp:DropDownList ID="DDL_ExportFileType" runat="server">
                                    <asp:ListItem Value="0" Text="Excel" />
                                    <asp:ListItem Value="1" Text="PDF" />
                                    <asp:ListItem Value="2" Text="Word" />
                                </asp:DropDownList>
                            </li>
                            <li class="right">
                                <asp:Button ID="BT_CreateExport" runat="server" Text="OK" OnClick="BT_CreateExport_OnClick" />
                                <asp:Button ID="BT_CreateReport" runat="server" Text="<%$ Resx : Reports_ContinueWithImmediateView %>" OnClick="BT_CreateReport_OnClick" />
                                <asp:Button ID="BT_Cancel" runat="server" Text="<%$ Resx : CancelVerb %>" OnClick="BT_Cancel_OnClick" />
                            </li>
                        </ul>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>

The UP_ExportPrompt updatepanel content is shown in Nyro modal window. After clicking the BT_CreateExport , excel file is created and send to the client with the Response object. I'm not pasting code for this because it's irrelevant to the problem.

Now, I tried creating the button as trigger with

<Triggers>
         <asp:PostBackTrigger ControlID="BT_CreateExport" />
</Triggers>

and it's not working again.

Anybody knows a solution of this problem ?

It's a known problem and "setting the button as trigger" solution appears to fix most of the cases with this problem here on SO ... but it's not working for me

The thrown error is:

0x800a139e - JavaScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

EDIT: Ok, I've managed to find more info on the issue. Even if I set the PostBackTrigger, the postback is still async. According to the documentation, the PostBackTrigger causes full postback to occur. In my case it doesn't, which is the problem.

Dimitar Tsonev
  • 3,711
  • 5
  • 40
  • 70
  • Have you tried changing UpdateMode to `UpdateMode="Conditional"` as well? – Yuriy Galanter Oct 02 '13 at 15:51
  • @YuriyGalanter ,yes I did that, too. I've tried everything I could think of. I don't know what's the cause of this. – Dimitar Tsonev Oct 02 '13 at 17:12
  • Another possibility - can you move `BT_CreateExport` button outside of UpdatePanel? – Yuriy Galanter Oct 02 '13 at 17:17
  • No, I can't. This update panel is opened in Nyro modal window. I have another button, which shows the modal window (which is the update panel content) – Dimitar Tsonev Oct 02 '13 at 17:42
  • I fact, I can change the whole workflow and somehow place the button outside the update panel. This will change the client's requirement, which is not an option. So the problem is "why there's no full postback triggered" – Dimitar Tsonev Oct 02 '13 at 17:45
  • Another 2 things to try - `ChildrenAstriggers="true"` attribute of the update panel and `enctype="multipart/form-data"` of the main form – Yuriy Galanter Oct 02 '13 at 20:09
  • By default ChildrenAsTriggers is set to true. Changin the enctype in the form also didn't work. I've put a breakpoint in the Page_Load event and I check the property IsInAsycPostBack of the ScriptManager. It is always true. – Dimitar Tsonev Oct 03 '13 at 07:00

1 Answers1

-1
  1. Read this article: Response.Write and UpdatePanel

  2. If you are using IE 10, write below code in PageLoad event:

    ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
    scriptManager.RegisterPostBackControl(this.BT_CreateExport);
    scriptManager.RegisterPostBackControl(this.BT_CreateReport);
    scriptManager.RegisterPostBackControl(this.BT_Cancel);
    

There is an incompatibility between MS AJAX Client Library 4.x (back-end of ASP.NET AJAX controls like UpdatePanel) and IE 10.

I write about that incompatibility to Microsoft Connect.

If your problem has been resolved, please vote up my report on Microsoft Connect.

Good Luck.

Community
  • 1
  • 1
Perseus
  • 330
  • 2
  • 8