This is a migrated thread and some comments may be shown as answers.

Disable right click on RadHtmlPlaceholder

12 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jayaseelan
Top achievements
Rank 1
Jayaseelan asked on 19 Apr 2012, 03:12 PM
Hi,
I have display html page in RadHtmlPlaceholder.how to prevent right click on RadHtmlPlaceholder.is't possible?Do you have any solution?

Regards
jayaseelan A

12 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 24 Apr 2012, 01:17 PM
Hi Jayaseelan,

If the html page displayed by the RadHtmlPlaceholder is on the same domain as the page hosting the Silverligt plug-in, then you can access the document DOM object inside the RadHtmlPlaceholder and attach an event handler for the oncontextmenu event.

I attached a sample project demonstrating this approach. Please give it a try and let me know if it helps.

Greetings,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jayanth
Top achievements
Rank 1
answered on 25 Apr 2012, 01:29 PM
hi Tina Stancheva,

                                    I a collegue of jayaseelan also working in the same problem I tried the project given by you,but still I am getting the right click option.Is there any other ways of achieving this.I dont want anyone to right click on my page,it is ok even it is a javascript.
0
Tina Stancheva
Telerik team
answered on 25 Apr 2012, 01:42 PM
Hi Jayanth,

The approach implemented in the solution I attached, works as expected on our side. This is why I am not sure why it doesn't work on yours - have you change the UrlSource of the RadHtmlPlaceolder? Where do you get the right click option? Can you send us a videocast demonstrating the behavior of the attached solution on your side?

Also, the same approach can be implemented in javascript, as long as you attach an event handler for the oncontextmenu event. You can have a look at this thread for more information. However, in the sample I prepared, I disabled only the right click on the content of the RadHtmlPlaceholder, not the entire Silverlight application. And also it is important to note that this solution only works when the WebPage hosting the RadHtmlPlaceholder Silverlight application is on the same domain as the external web page displayed by the RadHtmlPlaceholder. As you need access to the DOM structure of this page and you need to have access rights.

Greetings,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jayanth
Top achievements
Rank 1
answered on 26 Apr 2012, 06:58 AM
Hi Tina,

             Thanks for your reply.I then pasted the html file that you have attached along with this.I got the output ie.I wasnt able to right click the page.But the problem is if I give external URL like www.telerik.com I able to right click on the page.Is there any way to block the right click on those pages.I browsed into many sites I am not able to find anythind related to my criteria.Can you help me out regarding this.
0
Tina Stancheva
Telerik team
answered on 30 Apr 2012, 03:09 PM
Hello Jayanth,

Unfortunately the RadHtmlPlaceholder won't give you access to the Document DOM object of an external page unless you have the proper cross-domain settings. So you can try disabling the ContextMenu on the Silverlight application as a whole. If that is a possible solution for you, you can have a look at this thread that might help.

Greetings,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jayanth
Top achievements
Rank 1
answered on 02 May 2012, 11:56 AM
Hi tina,

             thanks for your reply.I have went throught the thread and worked on it already but it doesnt meet our requirement.But while browsing I saw one known as Radwindow with the help of that I think so I can achieve something.But I am not getting namespace for the Radwindow in the project given by yours should I give one more refrence for radwindow or it is a seperate DLL.Can you help me out on this.
0
Tina Stancheva
Telerik team
answered on 02 May 2012, 11:59 AM
Hello,

In order to use RadWindow in your application, you need to reference both Telerik.Windows.Controls.dll and Telerik.Windows.Controls.Navigation.dll. You can fin more information on the RadControls assembly dependancies here.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jayanth
Top achievements
Rank 1
answered on 02 May 2012, 12:04 PM
Hi tina,

           Yeah I saw this namespace when I was browsing for radwindow Telerik.Windows.Controls.Navigation is this available in the project given by you.




Thanks & Regards 

      Jayanth

 
0
Jayanth
Top achievements
Rank 1
answered on 02 May 2012, 02:42 PM
Hi tina,

             I added the refrence for windows.control.navigation.dll and I did the same as menioned for the integration.But it throwing me an exception "Value does not fall within the expected range."
0
Tina Stancheva
Telerik team
answered on 02 May 2012, 02:44 PM
Hi Jayanth,

I am not sure what migth be causing this exception. Can you please send us a sample project reproducing it so that we can better understand your scenario and sugegst a solution? Thank you in advance.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Richa
Top achievements
Rank 1
answered on 14 Jun 2012, 06:04 AM
Hi Jayanth,

I am providing HtmlSource to RadHtmlPlaceholder, then how can i disable right click on it.
0
Petar Mladenov
Telerik team
answered on 18 Jun 2012, 12:47 PM
Hi Richa,

 If you use the HTMLSource property  you can use the OnContextMenu of the iframe like so:

void htmlplaceholder_Loaded(object sender, RoutedEventArgs e)
        {
            HtmlElement iframe = (HtmlElement)htmlplaceholder.HtmlPresenter.Children[0];
            iframe.AttachEvent("oncontextmenu", this.OnContextMenu);
        }
 
 
        private void OnContextMenu(object sender, System.Windows.Browser.HtmlEventArgs e)
        {
              e.PreventDefault();
        }
You can find this realized in the attached sample. All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Jayaseelan
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Jayanth
Top achievements
Rank 1
Richa
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or