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

Clicking on link in HTMLPlaceholder navigates away from Silverlight app

9 Answers 140 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
Todd Millett
Top achievements
Rank 1
Todd Millett asked on 26 Aug 2009, 04:11 PM
Using the latest trial version of the Silverlight 3 control suite, I have successfully integrated the HTMLPlaceholder into a sample app.  If I set the UriSource property to a webpage, and click on a link, the HTMLPlaceholder navigates to the new webpage and displays it within the HTMLPlaceholder region in the Silverlight app.

However, if I set the HTMLSource property to something like this:

this.htmlPlaceholder.HtmlSource = @"Go to <a href=""http://www.yahoo.com/"">www.yahoo.com</a>";

when I click on the link the browser window navigates to yahoo.com, and I lose my Silverlight app.

I'm looking to use this to display HTML documents that have been archived, and I have no control over the content, and can't modify the HTML on the fly.  Is there a way to tell the control that when links are clicked they should be displayed in the HTMLPlaceholder control?  If that is not possible, can I cause them to be displayed in another browser window or in a new tab?



9 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 27 Aug 2009, 06:17 AM
Hi Todd Millett,

If you wan to use the RadHtmlPlaceholder in such scenario you will need to create a simple local html page containing the html that you are setting as a value to the HtmlSource property. The you need to reference this page with the SourceUri = "MyLocalPage.html". that way the links will be opened inside the html placeholder.

The explanation behind this is that when you use the SourceUri property the HtmlPlaceholder creates Iframe internally and renders the page there. Otherwise when the HtmlSource property is used the html is rendered in the same page where the Silverlight application is rendered.

Greetings,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Todd Millett
Top achievements
Rank 1
answered on 27 Aug 2009, 04:51 PM
Thanks for the info, but I'm not really sure how to implement this workaround.

We're getting the data as a stream from a webservice.  The data is dynamic, and changes with each call.  I thought about creating a local html file in Isolated storage, and then handing the path of that file to the SourceUri.  However, I can not access the file in Isolated Storage with a directory path.  Silverlight can't read or write to any other local file.

The file could be created on the server, and the SourceUri could point to it, but that introduces a whole different set of issues.

1. We would have to create a unique file for each user of the application, so that data is not clobbered from one user to the next.
2. We would have to implement some cleanup mechanism to clean up the files, in case the user closes the browser window or navigates away from the Silverlight app -- I've been down that road before, and it's not pretty.
3. There is a security risk of leaving those files around -- the archived HTML data could contain confidential information.

Can you suggest a way to implement this approach which would get around the above concerns?
0
Todd Millett
Top achievements
Rank 1
answered on 27 Aug 2009, 07:49 PM
A related issue:

Apparently, when the HTMLPlaceholder object is instantiated, an HTML element is added to the web page that is hosting the Silverlight application.  In Firefox, when the user clicks on a link in the HTMLPlaceholder that causes the browser to navigate away from the Silverlight page to a new page, this element is cached.  When the user presses the "Back" button to go back to the Silverlight page, the HTML element from the first instance of the Silverlight page is still on the page, and results in the old HTML text overlaying the new instance of the Silverlight application.

 I've been able to place a breakpoint in my App.xaml, and can see that the HtmlPage.Body has an extra "div" element, which I assume is the HTMLPlaceholder from the previous instance of the app.  In fact, if you press Forward and Back multiple times, an additional HTMLPlaceholder element gets added to the hosting page each time, so that you end up with multiple overlays of HTML from previous instances.

Is there a way I can clear any previous instances of the HTMLPlaceholder element from the hosting page when my Silverlight application initializes, so that it does not affect a new instance of the Silverlight application?

This is not an issue in IE or Safari -- only Firefox.
0
Valentin.Stoychev
Telerik team
answered on 28 Aug 2009, 07:31 AM
Hello Todd Millett,

you have an interesting scenario with the dymanic data. In this case you can create a static html page which you can refer from the HtmlPlaceholder. then when your data comes (from a services, DB, IDK) you can dynamically populate the static html page with the html string. Please let us know if you need help doing that. You can check this KB as a reference about how to access dynamically the placeholder content:
http://www.telerik.com/support/kb/silverlight/htmlplaceholder/htmlplaceholder-javascript.aspx

As for your second request - we will investigate and fix the problem. Thank you for your report.

Kind regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Todd Millett
Top achievements
Rank 1
answered on 02 Sep 2009, 04:26 PM
Thanks for your reply.  I am temporarily solving the dangling "div" issue by clearing out any content from the HTMLPlaceholder in the Application_Exit event, so that it does not impact the next instance of the application.  On Application_Startup I'm also looking at the host web page, and removing the extra div.  This is definitely a short-term workaround, since the div that is added for the HTMLPlaceholder does not have an ID, and I can't guarantee that I'm not deleting the wrong "div".

I look forward to seeing a fix in your next version.
0
Srinivas
Top achievements
Rank 1
answered on 02 Sep 2009, 07:45 PM
Hello Valentin,

In your first response you mentioned....
    If you wan to use the RadHtmlPlaceholder in such scenario you will need to create a simple local html page containing the html that you are setting as a value to the HtmlSource property. The you need to reference this page with the SourceUri = "MyLocalPage.html". that way the links will be opened inside the html placeholder.

In our case, the target HTML page URL is unknown as the user can specify anything there, including FTP:// etc. I am not sure how to create a dummy html page and change its contents dynamically so that the proper contents are loaded inside RadHtmlPlaceholder.

In our Silverlight application framework, we are creating RadTabItems dynamically and loading the requested contents like XAML pages, OCX control plug-ins and HTML contents inside RadTabItems. We want all these pages to load inside the RadTabItems using RadHtmlPlaceholder. 

Can you please suggest a workaround for this issue? It is very urgent.

Thank you very much
Srinivas 
0
Miroslav
Telerik team
answered on 04 Sep 2009, 02:26 PM
Hi Srinivas,

I am sorry for the delayed reply,

You do not need to create a local page to display its contents in the HtmlPlaceholder.

Just the SourceUri property needs to be set, it can point to an external page. Then when the user clicks on a link the navigation will remain in the same HtmlPlaceholder.

Sincerely yours,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Srinivas
Top achievements
Rank 1
answered on 05 Sep 2009, 12:55 AM

Hello Miroslav,

Here is the code that I am using to load external web pages:

Page Name: BrowserPlugin.xaml

XAML:
<telerik:RadHtmlPlaceholder x:Name="radPluginHolder" RespectSilverlightLayoutMeasure="True"

 

 

HorizontalAlignment="Left" VerticalAlignment="Top"></telerik:RadHtmlPlaceholder>

Code behind:
 

 

 

Uri

 

url = new Uri(Params["_RequestedPage"], UriKind.RelativeOrAbsolute);

 

 radPluginHolder.SourceUrl = url;

Params["_RequestedPage"] will have the external page URL. When I load BrowserPlugin.xaml inside a RadTabItem the web page is not getting loaded inside the RadHtmlPlaceHolder but instead it is throwing the Silverlight application and loading inside the IE browser. I remember this was working OK when I used Silverlight 2 controls but now it is behaving differently.

Interestingly, I notice that this behavior is random. Sometimes all pages are loaded inside the placeholder but suddently the behavior changes and loads the page inside the browser and removes my silverlight application. As a sample, I loaded http://www.google.com/ and http://www.cnn.com/ . When I try clicking the links they open inside the placeholder and inside my tab control and everything looks fine. But if I keep clicking those links several times then suddently the behavior changes. I would say 4 out of 10 times it behaves incorrectly.

Please let me know if you need any further details.

Thanks for your help on this.

Regards,
Srinivas

 

 

 

 

0
Valentin.Stoychev
Telerik team
answered on 07 Sep 2009, 08:59 AM
Hi Srinivas,

The issue you are experiencing is strange. Can you open a support ticket and attach a sample project where the issue is reproducible.

Thanks!

Sincerely yours,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
HTMLPlaceHolder
Asked by
Todd Millett
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Todd Millett
Top achievements
Rank 1
Srinivas
Top achievements
Rank 1
Miroslav
Telerik team
Share this question
or