Html source code

8 posts, 0 answers
  1. Martin Durao
    Martin Durao avatar
    13 posts
    Member since:
    Oct 2009

    Posted 06 Oct 2011 Link to this post

    Hello Support

    Is there some way to get the source html code received for the HtmlPlaceHolder control?

    Thanks in advance.
    Martin
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 11 Oct 2011 Link to this post

    Hello Martin,

    I am not sure I understand your request. Can you please elaborate?

    Basically the RadHtmlPlaceholder allows you to display external pages by using an IFrame object to display the SourceUrl. The IFrame obect is placed on top of the Silverlight plug-in in the page hosting the SL application and this is why the control's content is positioned over the whole Silverlight application.

    If you want to display html code, you can pass it as string to the RadHtmlPlaceholder HtmlSource property. In that case the HtmlSource will be placed in a div element inside the page hosting the Silverlight application.

    When you display an external page in the RadHtmlPlaceholder, you can access the content of the IFrame object like so:
    HtmlElement iframe = (HtmlElement)myHtmlPlaceHolder.HtmlPresenter.Children[0];
    HtmlWindow contentWindow = iframe.GetProperty("contentWindow") as HtmlWindow;
    HtmlDocument document = contentWindow.GetProperty("document") as HtmlDocument;
    Then you can either look for a specific element on the page, like so:
    HtmlElement content = document.GetElementById("contentID"); or you can add new element in the HtmlDocument document.

    I hope this information will be helpful. However, let me know if I can further assist you.

    Best wishes,
    Tina Stancheva
    the Telerik team

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

  3. DevCraft banner
  4. Lee
    Lee avatar
    11 posts
    Member since:
    Sep 2010

    Posted 16 Nov 2011 Link to this post

    Hello Support,
     
    I have been trying to access the contents of the IFrame object with the following code:

    Dim oRadHTML = DirectCast(parameter, Telerik.Windows.Controls.RadHtmlPlaceholder)
    Dim iframe As HtmlElement = DirectCast(oRadHTML.HtmlPresenter.Children(0), HtmlElement)
    Dim contentWindow As HtmlWindow = TryCast(iframe.GetProperty("contentWindow"), HtmlWindow)
    Dim document As HtmlDocument = TryCast(contentWindow.GetProperty("document"), HtmlDocument)
     
    It's always returning "nothing" when trying to get the HtmlDocument.
    Would there be something that I have missed when trying to retrieve the contents?
     
    Thanks,
    Lee
     
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 21 Nov 2011 Link to this post

    Hello Lee,

    I wasn't able to reproduce your issue. Can you please have a look at the attached sample and let me know if it works for you? 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 >>

  6. Lee
    Lee avatar
    11 posts
    Member since:
    Sep 2010

    Posted 22 Nov 2011 Link to this post

    Hello Tina,

    I downloaded your sample and updated  the code so that the sourceURL is an external webpage. I changed the sourceURL to the webpage I want to preview. The RadHTMLPlaceHolder can preview webpage but apparently, it's unable to retrieve the HTMLDocument on the external webpage.

    For retrieving the HTML Document, does the webpage need to be stored internally in the solution?

    Kind Regards,
    Lee

  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 23 Nov 2011 Link to this post

    Hello Lee,

    Thank you for getting back to us and elaborating on your scenario. I have missed the fact that you might be displaying a page from a different domain in the RadHtmlPlaceholder.

    You can access the IFrame.ContentWindow document property only on your domain or on domain with appropriate cross-domain policy. So setting up a cross-domain policy can help you overcome this issue.

    In a cross-domain call the Silverlight first looks for the clientaccesspolicy.xml file. If this file doesn't exists it will look for the crossdomain.xml file. More information about how to set up these files you can find here.

    All the best,
    Tina Stancheva
    the Telerik team

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

  8. Lee
    Lee avatar
    11 posts
    Member since:
    Sep 2010

    Posted 29 Nov 2011 Link to this post

    Hi Tina,

    I have altered the sample that you have provided. I change the SourceURL and added the crossaccesspolicy.xml and crossdomain.xml to the sample. It still doesn't work for me. Always getting the HTML Document as "Nothing".
    I have provided screen shoots of what I have done to the sample.
    Would you please advise me with what I'm doing wrong please.

    Kind Regards,
    Lee
  9. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 02 Dec 2011 Link to this post

    Hi Lee,

     Could you please tell me which URL you are trying to access. The crossdomain.xml file must be part of the website you are trying to access.

    Greetings,
    Kiril Stanoev
    the Telerik team

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

Back to Top
DevCraft banner