views:

2605

answers:

3

Hi guys, this should be simple...could someone provide me a simple code sample that has an aspx page hosting both a silverlight app (consisting of, say a button) and an iframe (pointing to, say stackoverflow.com). The silverlight app and iframe could be in separate div's, the same div, whatever.

Everything I've tried so far leaves me with a page that has no silverlight control rendered on it.

Thanks :)

EDIT: At the request for what my xaml looks like (Plus I should point out that my controls render just fine if I comment out the iframe.)

<UserControl x:Class="SilverlightApplication1.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;   


    <Grid x:Name="LayoutRoot" Background="Pink">
        <Button Content="Click Me!"/>
    </Grid>
</UserControl>

Thats it. Just for good measure here is my aspx page...

<form id="form1" runat="server">

         <asp:ScriptManager ID="ScriptManager1" runat="server"/>
        <div  style="height:100%;">            
            <asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClientBin/SilverlightApplication1.xap"    MinimumVersion="2.0.30523" Width="400" Height="400" />        
        </div>        

        <iframe src ="http://www.google.com" width="400"/>

    </form>
+1  A: 

Hmm, sound a bit odd, a quick google gave me this top result which talks about using an Iframe and Silverlight on the same page, without problems.

Also a quick test with the following code:

<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;">
<head runat="server">
    <title>Test Page</title>
</head>
<body style="height:100%;margin:0;">
    <form id="form1" runat="server" style="height:100%;">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div  style="height:100%;">
            <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/Test.xap" MinimumVersion="2.0.30523" Width="400" Height="400" />
        </div>
        <iframe src ="http://www.google.com" width="400"></iframe>
    </form>
</body>
</html>

Renders out both Silverlight and the Iframe quite happily.

What code were you using when trying and it didn't work?

Ola Karlsson
Thats exactly the code I tried and I still don't see the button displayed. All I see is empty space (although it is the silverlight host) and then the iframe at the bottom...no silverlight controls.Weird.
Hovito
A: 

What does your XAML look like?

It could be something along the lines of the size set on the usercontrol in XAML, doesn't match the size set on the plugin on the aspx page. In that case, your button might be there but just not in the viewable area... Try checking the size of things, make sure they match.

A quick test you could do is to change the background color of your root element in the XAML and see if anything happen on the page.

Also, does the silverlight work if you remove the Iframe but leave everything else as is?

Sorry if this a too simple suggestion but without knowing your experience level with XAML...

Ola Karlsson
A: 

Funny enough, I just solved this issue by ensuring that I specify the iframe dimensions by pixel.

Hovito