Skip to main content

Microsoft Silverlight

Answered Question Displaying multiple silverlight 2 pages on the same HTML pageRSS Feed

(0)

stewhall
stewhall

Member

Member

2 points

2 Posts

Displaying multiple silverlight 2 pages on the same HTML page

Is it possible to display more than 1 silverlight 2 page on a single HTML page?

I have Page1.xaml and Page2.xaml and they both need to be shown at the same time.
I could do this with silverlight 1.1 alpha, but cannot work out how to do this in silverlight 2.

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP
Answered Question

Re: Displaying multiple silverlight 2 pages on the same HTML page

If you want to show the multiple Silverlight controls, there are two options.

Option #1: You can create multiple Silverlight projects and use them in ASP.NET. This is the easiest way to do.

Option #2: If you don't want to create multiple projects then you can use initParams of Silverlight control to pass the parameter from ASP.NET project to Silverlight project.

For example:

Let's say we have one asp:Silverlight control  in two content pages.

Content1 (aspx)

 <asp:Silverlight ID="Silverlight1" InitParameters="PageId=1"  runat="server" Height="100px" Width="100px">
        </asp:Silverlight>

Content1 (html)

 <div id="silverlightControlHost">
        <object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%">
            <param name="source" value="RichText.xap"/>
            <param name="onerror" value="onSilverlightError" />
            <param name="background" value="white" />
            <param name="initParams" value="PageId=1" />

            <a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;">
                 <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
            </a>
        </object>
        <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
    </div>

Content2 (aspx)

 <asp:Silverlight ID="Silverlight1" InitParameters="PageId=2"  runat="server" Height="100px" Width="100px">
        </asp:Silverlight>

Content2 (html)

 <div id="silverlightControlHost">
        <object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%">
            <param name="source" value="RichText.xap"/>
            <param name="onerror" value="onSilverlightError" />
            <param name="background" value="white" />
            <param name="initParams" value="PageId=2" />

            <a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;">
                 <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
            </a>
        </object>
        <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
    </div>

 

App.xaml.cs


private void Application_Startup(object sender, StartupEventArgs e){

    int pageID = int.Parse(e.InitParams["PageId"]);
    if(pageID == 1){
              this.RootVisual = new Page1();

    }
   else{

        this.RootVisual = new Page2();
  }

 
}

 


(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


stewhall
stewhall

Member

Member

2 points

2 Posts

Re: Displaying multiple silverlight 2 pages on the same HTML page

Many thanks for your help, that is just what I wanted to do.

Thanks again

Stew.

alexchiri
alexchiri

Member

Member

2 points

1 Posts

Re: Displaying multiple silverlight 2 pages on the same HTML page

 Hello

 I want to put 2 or more Silverlight pages in an html and every page should be placed in a <td> tag of a html table.

The problem is that when I put the div with the Silverlight page into the <td> tag the page doesn't appear.

Outside the table it appears. 

Are there any issues with tables an Silverlight pages in html?

P.S. I used Silverlight 2 beta 2

-- edited later:

I figured it out: you have to put the size of the page as parameters of the <object> tag.

Default is width=100% and height=100%. With these values the page will not show up in a table.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities