I have code that "pops up" another ASPX page with an image in it. The javascript used to popup the the window is below.
string url = @"DocumentPage.aspx?imageGuid=" + imageGuid;
string winWidth = "800";
string winHeight = "600";
StringBuilder scriptString = new StringBuilder();
scriptString.Append("<script language='JavaScript'> function openDocument(){");
scriptString.Append("var url = " + "'" + url + "';");
scriptString.Append("var wndw = window.open(url,'','width= " + winWidth + ",height=" + winHeight + ",resizable=Yes,status=Yes,scrollbars=Yes,menubar=Yes');");
scriptString.Append("if ((document.window != null) && (!wndw.opener)) wndw.opener = document.window;");
scriptString.Append("} openDocument();<");
scriptString.Append("/");
scriptString.Append("script>");
The image renders in this DocumentPage.aspx fine. In IE 7 when I click the File -> Print, this action alone causes this DocumentPage.aspx to fire a PostBack and the Page property of IsPostBack is false, so it essentially runs through the same code it executed on page pop up.
Has anyone run across this Browser -> File -> Print causing post backs in asp.net? If so do you have a work around to stop this? (Its not doing anything to break the pages functionality, its just really annoying for wasting resources with unneeded postback calls).