In my application, I have a form that contains a browser control in which I display an SSRS report. I would like to prevent the user from right-clicking in the browser control and being shown the popup menu. Ideally I'd like the right-click to do nothing. Is there a way I can accomplish this?
You can set the IsWebBrowserContextMenuEnabled equal to false. You will probably also want to set AllowWebBrowserDrop equal to false too so they cant drag a url into the app and have it load.
webBrowser1.IsWebBrowserContextMenuEnabled = false;
webBrowser1.AllowWebBrowserDrop = false;
for any case, winform or wpf:
private void WebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
((WebBrowser)sender).InvokeScript("eval", "$(document).contextmenu(function() { return false; });");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With