how to hide placeholder control on App Exit

1 posts, 0 answers
  1. Jeff Moeller
    Jeff Moeller avatar
    1 posts
    Member since:
    Jan 2010

    Posted 03 Jun 2011 Link to this post

    We are hosting multiple silverlight applications in the same ASP page and using javascript to swap silverlight applications (swap the contents of a div). When we swap out an application that was hosting a RadHtmlPlaceholder control, the application exits, but any RadHtmlPlaceholder iframe elements remained visible on top of the newly swapped-in application.

    OnUnload() does not seem to be called when exiting the silverlight application in this manner, and we suspect this is the root of this issue. Setting IsVisible to Collapsed and calling UpdateLayout() did not seem to work from Application_Exit(). However, we were able to come up with a solution...

    We implemented logic in Application_Exit() to search the root visual's descendants for all RadHtmlPlaceholder controls. We then removed each child HtmlElement in the RadHtmlPlaceholder control's HtmlPresenter as follows:
    var htmlChildren = htmlPlaceholder.HtmlPresenter.Children;
    foreach (var child in htmlChildren) 
         htmlPlaceholder.HtmlPresenter.RemoveChild(child as HtmlElement);

    Hopefully this solution will help someone else...
Back to Top