I’m adding some functionality to an existing ‘popup’ in an ASP.NET website. The popup is called by window.showmodaldialog because the website only needs IE support and well, … it was just programmed that way many years ago.
Now when I try to stream an image ( show a save file dialog ), this code does not work. It does work on normal pages, and anything that isn’t a modal dialog.
protected void ButtonExport_Click(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "image/png";
Response.AddHeader("content-disposition", "attachment;filename=print.png");
MemoryStream img = DayPilotCalendar1.Export(ImageFormat.Png);
img.WriteTo(Response.OutputStream);
Response.End();
}
Is there any reason why this does not work? It’s simply not displaying anything when I click the button, but it does go through the code.
Because window.showModalDialog opens a modal dialog which blocks the parent window. So the browser window is blocked and it is unable to show the Save dialog.
You can try to use window.showModelessDialog instead