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. Printing from a webpage

Printing from a webpage

Scheduled Pinned Locked Moved Web Development
csharpquestionasp-net
3 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.
  • G Offline
    G Offline
    Gavin_Mannion
    wrote on last edited by
    #1

    Hi All, I am using ASP.NET and C# I would presume this is an easy question but I can't seem to find any information about it. I would like to add a button to my webpage that when clicked acts just like the print option of Internet Explorer. ie. Brings up a box to ask you what printer you want to print. I'm sure there must be a straight function that I can call, something like Document.Print? Thanks, Gavin

    R 1 Reply Last reply
    0
    • G Gavin_Mannion

      Hi All, I am using ASP.NET and C# I would presume this is an easy question but I can't seem to find any information about it. I would like to add a button to my webpage that when clicked acts just like the print option of Internet Explorer. ie. Brings up a box to ask you what printer you want to print. I'm sure there must be a straight function that I can call, something like Document.Print? Thanks, Gavin

      R Offline
      R Offline
      Remco V
      wrote on last edited by
      #2

      code example:

      /*
      This script is written by Eric (Webcrawl@usa.net)
      For full source code, installation instructions,
      100's more DHTML scripts, and Terms Of
      Use, visit dynamicdrive.com
      */

      function printit(){
      if (window.print) {
      window.print() ;
      } else {
      var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
      document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
      WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
      }
      }

      var NS = (navigator.appName == "Netscape");
      var VERSION = parseInt(navigator.appVersion);
      if (VERSION > 3) {
      document.write('<form><input type=button value="Print this Page" name="Print" onClick="printit()"></form>');
      }

      source: http://www.dynamicdrive.com/dynamicindex9/other1.htm

      G 1 Reply Last reply
      0
      • R Remco V

        code example:

        /*
        This script is written by Eric (Webcrawl@usa.net)
        For full source code, installation instructions,
        100's more DHTML scripts, and Terms Of
        Use, visit dynamicdrive.com
        */

        function printit(){
        if (window.print) {
        window.print() ;
        } else {
        var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
        }
        }

        var NS = (navigator.appName == "Netscape");
        var VERSION = parseInt(navigator.appVersion);
        if (VERSION > 3) {
        document.write('<form><input type=button value="Print this Page" name="Print" onClick="printit()"></form>');
        }

        source: http://www.dynamicdrive.com/dynamicindex9/other1.htm

        G Offline
        G Offline
        Gavin_Mannion
        wrote on last edited by
        #3

        Thanks a million, Works like a treat

        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