Disable right click on RadHtmlPlaceholder

13 posts, 0 answers
  1. Jayaseelan
    Jayaseelan avatar
    2 posts
    Member since:
    Apr 2012

    Posted 19 Apr 2012 Link to this post

    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
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 24 Apr 2012 Link to this post

    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 >>

  3. Jayanth
    Jayanth avatar
    7 posts
    Member since:
    Apr 2012

    Posted 25 Apr 2012 Link to this post

    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.
  4. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 25 Apr 2012 Link to this post

    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 >>

  5. Jayanth
    Jayanth avatar
    7 posts
    Member since:
    Apr 2012

    Posted 26 Apr 2012 Link to this post

    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.
  6. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 30 Apr 2012 Link to this post

    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 >>

  7. Jayanth
    Jayanth avatar
    7 posts
    Member since:
    Apr 2012

    Posted 02 May 2012 Link to this post

    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.
  8. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 02 May 2012 Link to this post

    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 >>

  9. Jayanth
    Jayanth avatar
    7 posts
    Member since:
    Apr 2012

    Posted 02 May 2012 Link to this post

    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

     
  10. Jayanth
    Jayanth avatar
    7 posts
    Member since:
    Apr 2012

    Posted 02 May 2012 Link to this post

    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."
  11. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 02 May 2012 Link to this post

    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 >>

  12. Richa
    Richa avatar
    4 posts
    Member since:
    Jul 2012

    Posted 14 Jun 2012 Link to this post

    Hi Jayanth,

    I am providing HtmlSource to RadHtmlPlaceholder, then how can i disable right click on it.
  13. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3151 posts

    Posted 18 Jun 2012 Link to this post

    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 >>

Back to Top