0

I am creating a Purchase Order PDF at the click of a button using Response.Write.

    Response.ContentType = "pdf/application";
    Response.AddHeader("content-disposition", "attachment;filename=PurchaseOrder.pdf");
    Response.OutputStream.Write(ms.ToArray(), 0, ms.ToArray().Length);

After that, I try to update the screen to show that the order has been raised:

    labelReqPOStatus.Text = "PO Raised";

The screen does not get updated. How can I get it to do so?

Steve Staple
  • 2,983
  • 9
  • 38
  • 73
  • Is ms a memory stream? If so do you set the position on it to 0 before calling ToArray()? also Response.End() may help – Victor Jul 24 '14 at 11:34
  • 1
    You simple cannot do that ! Same answer http://stackoverflow.com/questions/14760154/response-transmitfile-nothing-happening/14760372#14760372 – Aristos Jul 24 '14 at 11:36

1 Answers1

1

As mentioned by Aristos - this is not possible. What you can do is to

1) update your page first

labelReqPOStatus.Text = "PO Raised";

2) as part of this update add javascript code to start download of actual pdf (assuming you have "Handler1.ashx" that will serve the file like you've mentioned)

ClientScript.RegisterClientScriptBlock(GetType(), "Download", "window.open('Handler1.ashx')", true); 
Ondrej Svejdar
  • 21,349
  • 5
  • 54
  • 89