Martin Durao
Top achievements
Rank 1
Martin Durao
asked on 06 Oct 2011, 08:56 AM
Hello Support
Is there some way to get the source html code received for the HtmlPlaceHolder control?
Thanks in advance.
Martin
Is there some way to get the source html code received for the HtmlPlaceHolder control?
Thanks in advance.
Martin
7 Answers, 1 is accepted
0
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:
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
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;
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 >>
0
Lee
Top achievements
Rank 1
answered on 17 Nov 2011, 12:55 AM
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
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
0
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
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 >>
0
Lee
Top achievements
Rank 1
answered on 23 Nov 2011, 12:29 AM
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
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
0
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
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 >>
0
Lee
Top achievements
Rank 1
answered on 30 Nov 2011, 01:16 AM
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
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
0
Hi Lee,
Kiril Stanoev
the Telerik team
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 >>