Disable right click on embedded PDF in ASP.NET Web form

hi

I am trying to achieve by using javascript here in the code sample but is not able to get it to work. I am wondering if GroupDocs Viewer is able to achieve that? Thanks

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="testingPDF.aspx.cs" Inherits="testingPDF" %>

@sg225551,

GroupDocs.Viewer doesn’t provide any built-in option to disable right click in the front end application. However, you can easily achieve it using the JavaScript in .aspx page. The one possible way is to use oncontextmenu=“return false” in the body tag as shown below:

<body oncontextmenu="return false"> 
...
...
</body>

Furthermore, you can also have a look at our open source document viewer application which is built in ASP.NET Web Forms and it provides the feature of disabling right click. You can download the application from here.

Thanks for the reply Aziz, I have tried your proposed solution before but it doesn’t work. thanks

@sg225551,

You can also try other options (available at different programming communities) that may fit your requirement and work correctly at your end, for example, disabling context menu using event listener (see this). Hope it helps.