C # disable hyperlink redirection, Script Error prompt, default right-click menu, and shortcut keys in the webbrowser Control

Source: Internet
Author: User

Since vs2005, The webbrowser control provided by vs has been quite friendly and highly controllable.

Winform works with webbrowser for UI development. It is also a very smooth mode. Microsoft vs ide installation programs are basically in this mode.

When using webbrowser for UI, we sometimes do not want the link to be clicked by users, do not want to pop up an annoying Script Error prompt box, and do not want users to right-click the IE menu, to do this, it is actually very easy...

Error script disabling prompt

Set scripterrorssuppressed of the webbrowser control to true.

Disable right-click menu

Set iswebbrowsercontextmenuenabled of webbrowser to false

Disable shortcuts

Set webbrowsershortcutsenabled of webbrowser to false

Disable hyperlink

There are two types of hyperlinks:

Direct switch of current window

, One is

Open in new window


Of course, direct window redirection

:

Set allownavigation of webbrowser to false


Open in new window

:

To disable the opening of a new window, you must handle the newwindow event of webbrowser.

Private void webbrowser1_newwindow (Object sender, canceleventargs E)

{

E. Cancel = true;

}

After the above work is done, it is basically finished. The last point should be noted, that is, drag-and-drop.

Remember to set allowwebbrowserdrop of webbrowser to false.

Source: DIY tribe (
Http://www.diybl.com/course/4_webprogram/asp.net/asp_netxl/20081119/152021.html
)

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.