How to SHIELD software from system hotkeys in B/S mode (C #)

Source: Internet
Author: User
Sometimes JavaScript code cannot be used when using a framework webpage. I have encountered this situation, but I have to block some key values, so I only need to write code in C, you can add some key values as needed! Public void hideallfunction (page)

{

If (! Page. isstartupscriptregistered ("msghideallfunction "))

{

String clientscript = @ "<script language = JavaScript> 〉

  

Function keydown (){

If (window. event. altkey) & (window. event. keycode = 37) | (window. event. keycode = 39) // mask Alt + direction keys ↓ // mask Alt + direction keys →

{

  

Event. returnvalue = false ;;

}

If (event. keycode = 116) // block the F5 refresh key

{

Event. keycode = 0 ;;

Event. returnvalue = false ;;

}

If (event. ctrlkey) & (event. keycode = 78) // block Ctrl + n

{

Event. returnvalue = false ;;

}

If (event. shiftkey) & (event. keycode = 121) // block SHIFT + F10

{

  

Event. returnvalue = false ;;

}

If (event. keycode = 122) // block F11

{

Event. keycode = 0 ;;

Event. returnvalue = false ;;

}

}

Function nocontextmenu ()

{

Event. cancelbubble = true

Event. returnvalue = false ;;

Return false ;;

}

Document. onkeydown = keydown ;;

Document. oncontextmenu = nocontextmenu ;;

  

  

  

</SCRIPT> 〉";;

Page. registerstartupscript ("msghideallfunction", clientscript );;

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.