2

I am working on ASPx Web Forms Page and have problem with printing page.

I have button 'Print' which calls event (print method):

private void MenuPrint_ItemClick(object sender, DevExpress.Web.ASPxMenu.MenuItemEventArgs e)
        {
Response.RedirectOn("Print.aspx", "_blank", "menubar=0,scrollbars=1,width=780,height=900,top=10");
        }

after I press 'Print' button it opens new window 'Print.aspx' and this is which is on this Page:

protected void Page_Init(object sender, EventArgs e)
        {
            LoadData(); // generate print document
            Response.Write("<script language=javascript>window.print();</script>");
        }

and now it's the problem:

window.print(); will open google chrome printing menu, which block old window (that window where is 'Print' button. issue image

When I close Print.aspx by clicking [X] List.aspx windows will be still blocked. When I press 'Anuluj' - which means Cancel and then press [X] List.aspx won't be blocked. Eveything will be fine.

I make some research and figure out that there is no more options to print document, also I can't handle 'Cancel printing' button.

Question is how to avoid that block, maybe I should use something other instead RedirectOn?

boski
  • 1,106
  • 3
  • 21
  • 44
  • Maybe offer the client a "printable" version but don't invoke `window.print` yourself? Or at least wait until `LoadData` has finished before invoking it. – Paul S. Apr 23 '14 at 13:34
  • Even when I register script with 'window.onload = function() ' it's still 'loading' status of window... – boski Apr 23 '14 at 14:30

1 Answers1

4

This seems to be a bug of Chrome 34 - is this the Chrome version you are using? There is a similar question open here: Javascript window.print() in chrome, closing new window or tab instead of cancelling print leaves javascript blocked in parent window. No solution so far though.

Community
  • 1
  • 1
Alex
  • 101
  • 8