Silverlight App inside ASPX inside another Silverlight App's RadHtmlPlaceHolder

7 posts, 0 answers
  1. Lev Rosenblit
    Lev Rosenblit avatar
    16 posts
    Member since:
    May 2008

    Posted 10 Jun 2009 Link to this post

    I was wondering about the following scenario:
    I have a silverlight application that provides a navigation wrapper with cool transitions and visual effect for switching content. the silverlight application (lets call it: wrapperSL) has a RadHtmlPlaceHolders that the navigation loads a different aspx page into it when changed. Some aspx pages contain other silverlight applications.

    The reason i use the place holder and not just make xaml pages and load them, is that the application becomes very large when including all of those xaml's, and i have alot of code and controls already written in ajax.

    will this scenario work well? or will it slow everything down?
    are there better ways of accomplishing this?
    Is it wiser to have a bigger application size and have all the content in xaml's?

    Lev Rosenblit
  2. David
    David avatar
    3 posts
    Member since:
    Mar 2009

    Posted 10 Jun 2009 Link to this post

    Hi Lev,

    For intranet use a large Silverlight app is not a problem, but across the web loading several Mb of XAP content gets tedious if it is required frequently. There are guidlines on how long a page should load, to keep user attention, however so much depends on their connection speed. 

    The ideal approach is to dynamically download assemblies on demand as per the Telerik demo app, but it is obviously a bit more development work that way.

    Your nesting of Silverlight apps was an interesting idea so I tried to create a recursive Silverlight page. It turns out you cannot reference the same page in the RadHtmlPlaceHolder, but can reference any other Html/Silverlight page. The time overhead of loading the nested pages is on a par with dynamically loading assemblies. I have not checked overall memory usage yet, but performance seems the same.

    If you must use nested ASPX pages with Silverlight it will certainly work, but you lose the benefits of a single application written in one language. You might want to look at what features are must-have in your Ajax apps and make similar user/custom-controls in Silverlight.

    Given the things you can do easily in Silverlight vs Ajax (and develop much faster), I am usually inclined to build a single large Silverlight app initially and then break out assemblies for dynamically loading if the load time is too slow.  I noticed the RadEditor downloads a seperate RadEditorHelper.xap file, on demand, which is over 1Mb. It looks like Telerik made a similar decision when they built the RadEditor to keep it lean.

    Hope this helps. Thanks for sparking off interesting ideas on new ways to use the HtmlPlaceholder!


  3. Valentin.Stoychev
    Valentin.Stoychev avatar
    2198 posts

    Posted 10 Jun 2009 Link to this post

    Hi David,

    Just a note that the Editor XAP file is ~20k, not 1Mb.

    All the best,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. David
    David avatar
    3 posts
    Member since:
    Mar 2009

    Posted 10 Jun 2009 Link to this post

    My apologies Telerik,

    Quite right. Your version is 20Kb (mine was 1Mb... I broke my build from source by including local copy of all the DLLs referenced by RadEditorHelper) :)

  5. Lev Rosenblit
    Lev Rosenblit avatar
    16 posts
    Member since:
    May 2008

    Posted 11 Jun 2009 Link to this post

    Thanks for the replies.

    you are correct that its not possible to reference the same page when loading from a SL APP an ASPX (into a RadHtmlPlaceHolder) that has the same SL APP imbeded because it creates an infinit loop if it loads the app right away.
    But it is possible to reference the same SL APP if the RadHtmlPlaceHolder points for example to a site with a link to an ASPX with the same SL APP. if you click the link, you'll get the same SL APP in the RadHtmlPlaceHolder clicking it's link will get another SL APP and so on.

    Lev Rosenblit
  6. Eliza Sahoo
    Eliza Sahoo avatar
    29 posts
    Member since:
    Jan 2010

    Posted 02 Feb 2010 Link to this post

    One of the aim of Silverlight developer is to keep the size application package i.e .xap file as small as possible.The larger the XAP file, the longer it takes to download, and if it grows too large, Silverlight might be unable to load it.
    Below are the steps to load assembly on demand and with the benefits of strong typing.
    Step 1. Create a Silverlight Class library. 
    For example say "SampleLibrary"

    Step 2. Add a class to the SampleLibrary

    Public Class SampleClass
        Public Function SampleFunction() As String
    Return "From External library"
    End Function
    End Class
    Step 3. Create a Silverlight web application
    Step 4. Add Reference to SampleLibrary.  After adding reference right-click on the SampleLibrary reference and change the property "Copy Local" to false. This will keeping the Assembly out of the XAP.
    Step 5. Copy the assembly to ClientBin folder of web application where the .xap file resides.
    Step 6. Add following to to load Assembly.
    WebClient : Provides common methods for sending data to and receiving data from a resource identified by a URI.

            Dim wc As WebClient = New WebClient()
            AddHandler wc.OpenReadCompleted, AddressOf wc_OpenReadCompleted
    wc.OpenReadAsync(New Uri("SampleLibrary.dll", UriKind.Relative))

    After loading assembly from web server, AssemblyPart class's Load method loads it into the appdomain.
        Public Sub wc_OpenReadCompleted(ByVal sender As Object, ByVal e As System.Net.OpenReadCompletedEventArgs)
            Dim part As AssemblyPart = New AssemblyPart
            If Not e.Result Is Nothing Then
            End If
        End Sub
    Step 7. To use Strong Typing:   Do not create the on-demand assempbly class object inside wc_OpenReadCompleted as silverlight's JIT complier will come in the way. When JIT compiler compiles wc_OpenReadCompleted method, it scans the method, finds that it references a type named "SampleClass" so tries to load "SampleLibrary.dll" so that reference can be resolved. Unfortunately, this happens before the method is even executed.
    So always use the on-demand assembly classes in another method. In this way you can enjoy the benifits of strong typing
        Public Sub UseClassLibrary()
    Dim objSample As SampleLibrary.SampleClass = New SampleLibrary.SampleClass
            Show.Text = objSample.SampleFunction()

        End Sub
  7. anu
    anu avatar
    7 posts
    Member since:
    Feb 2010

    Posted 05 Feb 2010 Link to this post

    Hi Thanks for your reply..

    i am facing issue to load the silver light in my aspx page.

    i am getting error unhandled exception javascript error.

    i tested in my application for testing loaded only sliver light its working.

    but when i use in my aspx page(i have lot of code) its not working not loading silver light.
    i have written this code for load the silver light.

    <div id="silverlightControlHost">



    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">



    <param name="source" value="ClientBin/SilverlightApplication2.xap"/>



    <param name="onError" value="onSilverlightError" />



    <param name="background" value="white" />



    <param name="minRuntimeVersion" value="3.0.40624.0" />



    <param name="autoUpgrade" value="true" />



    <param name="Windowless" value="true" />



    <param name="EnableHtmlAccess" value="true" />



    <param name="initParams" value="DocSeqList=txtDocSeq" />



    <a href="" style="text-decoration:none">



    <img src="" alt="Get Microsoft Silverlight" style="border-style:none"/>






    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>




Back to Top