How to make a button do a full postback instead of asynchronous postback

In an ASP.NET 4.0 web application, I have a user control that is wrapped with an UpdatePanel (see code below).

<asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <UC:MyCustomCtrl ID="customCtrl" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel>

Obviously, this is great for every ASP.NET control that causes a postback in my user control because it makes it asynchronous. However , there is one process for which this does not work!

I have an ASP.NET (Create Report) button in a user control that makes an asynchronous request to the server. Then the server creates an Excel spreadsheet, and then puts the table in HttpResponse to send back to the client browser so that they can open / save it. However, it explodes at this point, because the server request is asynchronous and apparently you cannot put the binary in the HttpResponse during the asynchronous request.

How do I get around this?

+5
source share
4 answers

Register this button as synchronous feedback control in the user control Page_Loadmethod:ScriptManager.GetCurrent(Page).RegisterPostBackControl(CreateReportButton);

+11
source

, , ,

<Triggers>
     <asp:PostBackTrigger ControlID="customCtrl" EventName="ReportButtonClicked" />
</Triggers>
0

UpdatePanels, .

<asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <UC:MyCustomCtrl ID="customCtrl" runat="server" />
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID="btnID" />
    </Triggers>
</asp:UpdatePanel>
0

. , ...

<asp:UpdatePanel ID="UpdatePanel5" runat="server">
    <ContentTemplate>
        <UC:MyCustomCtrl ID="customCtrl" runat="server" />
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID="customCtrl$btnID" />
    </Triggers>
</asp:UpdatePanel>

- , , .

DOM ( Chrome) , "NAME" ( ). , , .

0

All Articles