How to Disable Print Screen on ASP.NET

Written by declan maher
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Disable Print Screen on ASP.NET
Build a secure website by disabling the "Print Screen" functionality. (security image by robert mobley from

In order to build a secure online examination system, the program should prevent users from using the "Print Screen" button. Otherwise, a user might copy the screen as a graphic and save the exam questions. You can disable this capability by overriding the "Print Screen" button with JavaScript.

Skill level:

Things you need

Show MoreHide


  1. 1

    Open a editor.

  2. 2

    Create an .aspx page.

  3. 3

    Add this JavaScript function to the page:

    <script language="javascript" type="text/javascript">

    function AccessClipboardData() {
        try {
    window.clipboardData.setData('text', "No print data");
        } catch (err) {

    txt = "Error on this page.\n\n";

    txt += "Error details: " + err.description + "\n\n";

    txt += "Click OK to continue.\n\n";



  4. 4

    Add this code which calls the function created in the previous step:

    set Interval("AccessClipboardData()", 300);

    This will overwrite anything that a user adds to the clipboard. When the user clicks on the "Print Screen" button, the screen picture copied to the clipboard will be deleted so the user will not be able to paste the screen.

  5. 5

    Save the .aspx file and run.

Tips and warnings

  • To improve the security of a page, you should also hide the data in HTML source and prevent a user printing a page.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.