views:

140

answers:

1

Can you imbed silverlight 4 xap files into an aspx page and then view them in vs 2008? If so how do you do this? Any sample code would be appreciated.

Thanks!

+1  A: 

Sure, why not? Simply add the XAP to your ASP.NET web project and add an tag to your ASPX. Here's the basic embed for a Silverlight app:

        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
      <param name="source" value="ClientBin/MyApp.xap"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50401.0" />
      <param name="autoUpgrade" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=4.0.50401.0" style="text-decoration:none">
          <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
      </a>
    </object>
Corey Schuman
so even though you wouldn't be able to edit the silverlight 4 xaml code in vs2008, you'd still be able to view the xap output in an aspx file within vs2008 environment? i.e. i'm wondering if i could use web developer 2010 to develop my silverlight 4 xap files, then debug in my aspx website in vs 2008
cfarm54
Yes. In VS 2008 you can add a xap much like an image, video, html file, etc. Then in your aspx page use the <object> embed. Additionally, you CAN use VS Web Developer 2010 create Silverlight 4 apps. Now, if you want to debug the Silverlight code, you'll need to do so from VS 2010. Debugging the ASP.NET project you'll use VS2008.
Corey Schuman