Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. print dialog pop up window, On click "Print" does not open the Print dialog box

print dialog pop up window, On click "Print" does not open the Print dialog box

Scheduled Pinned Locked Moved ASP.NET
questionjavascripthtmlannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    For_IT
    wrote on last edited by
    #1

    Hi, I have a javascript which I register on click of link button, using ScriptManager. My link button is in update panel, the link button click code is:

    protected void lnkButton_Click(object sender, EventArgs e)
    {
    StringBuilder sb = new StringBuilder();
    sb.AppendLine(" var popup = window.open( '','popup','toolbar=no,menubar=no,scrollbars=1,width=750,height=800');");
    sb.AppendLine("popup.document.write('<html><head>');");
    sb.AppendLine("popup.document.write('<title>Configurations for ACA</title>');");
    sb.AppendLine("popup.document.write('</head><body>');");
    sb.AppendLine("popup.document.write('<div id=\"lnk\" class=\"noprint\" style=\"text-align:right\">');");
    sb.AppendLine("popup.document.write('<a href=\"#\" onclick=\"window.print();return false;\">Print</a>');");
    sb.AppendLine("popup.document.write('<a href=\"#\" onclick=\"window.close();return false;\">Close</a>');");
    sb.AppendLine("popup.document.write('</div>');");
    sb.AppendLine("popup.document.write('<table border=1px style=width:500px; margin-left:100px; margin-top:50px; border-color:Maroon; >');");
    sb.AppendLine("popup.document.write('<tr><td>');");
    sb.AppendLine("popup.document.write('This is my string');");
    sb.AppendLine("popup.document.write('</td><td>')");
    sb.AppendLine("popup.document.write('This is my string');");
    sb.AppendLine("popup.document.write('</td></tr></table>');");
    sb.AppendLine("popup.document.write('</body></html>');");
    ScriptManager.RegisterClientScriptBlock(this.GetType(), "OpenWindow", sb.ToString(), true);
    }

    WHen I click on "print",window.print() do not pop uo printer selection dialog box. When I click on "close", it closes the window. Can anyone please suggest what is wrong in the javascript ? Many thanks.

    P 1 Reply Last reply
    0
    • F For_IT

      Hi, I have a javascript which I register on click of link button, using ScriptManager. My link button is in update panel, the link button click code is:

      protected void lnkButton_Click(object sender, EventArgs e)
      {
      StringBuilder sb = new StringBuilder();
      sb.AppendLine(" var popup = window.open( '','popup','toolbar=no,menubar=no,scrollbars=1,width=750,height=800');");
      sb.AppendLine("popup.document.write('<html><head>');");
      sb.AppendLine("popup.document.write('<title>Configurations for ACA</title>');");
      sb.AppendLine("popup.document.write('</head><body>');");
      sb.AppendLine("popup.document.write('<div id=\"lnk\" class=\"noprint\" style=\"text-align:right\">');");
      sb.AppendLine("popup.document.write('<a href=\"#\" onclick=\"window.print();return false;\">Print</a>');");
      sb.AppendLine("popup.document.write('<a href=\"#\" onclick=\"window.close();return false;\">Close</a>');");
      sb.AppendLine("popup.document.write('</div>');");
      sb.AppendLine("popup.document.write('<table border=1px style=width:500px; margin-left:100px; margin-top:50px; border-color:Maroon; >');");
      sb.AppendLine("popup.document.write('<tr><td>');");
      sb.AppendLine("popup.document.write('This is my string');");
      sb.AppendLine("popup.document.write('</td><td>')");
      sb.AppendLine("popup.document.write('This is my string');");
      sb.AppendLine("popup.document.write('</td></tr></table>');");
      sb.AppendLine("popup.document.write('</body></html>');");
      ScriptManager.RegisterClientScriptBlock(this.GetType(), "OpenWindow", sb.ToString(), true);
      }

      WHen I click on "print",window.print() do not pop uo printer selection dialog box. When I click on "close", it closes the window. Can anyone please suggest what is wrong in the javascript ? Many thanks.

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      sb.AppendLine("popup.document.write('<a href=\"#\" onclick=\"window.print();return false;\">Print</a>');");

      It is not work without return false; ?

      sb.AppendLine("popup.document.write('<a href=\"#\" onclick=\"window.print();\">Print</a>');");

      Parwej Ahamad R & D: REST services with WCF

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups