I created a simple Sharepoint web part which hosts a silverlight application. I created a user control which loads the usercontrol.ascx from the layouts path and loads it up.
public class SLSampleWP : System.Web.UI.WebControls.WebParts.WebPart
{
/// <summary>
/// Add the silverlight user control here
/// </summary>
protected override void CreateChildControls()
{
this.Title = "Silverlight Sample";
//silverlight control
Control ctrlSilverlight;
//load the user control
ctrlSilverlight = this.Page.LoadControl(@"/_layouts/SL.Samples/SL.Samples.AgeCategory.ascx");
//add the control
this.Controls.Add(ctrlSilverlight);
}
}
User Control (ascx)
<div id="silverlightControlHost">
Silverlight Web Part
<br />
<object data="data:application/x-silverlight," type="application/x-silverlight-2"
width="100%" height="100%">
<param name="source" value="/_layouts/SL.Samples/Silverlight.Samples.xap" />
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50917.0" />
开发者_高级运维 <param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight"
style="border-style: none" />
</a>
</object>
</div>
But I'm not getting the silverlight control rendered in the page. What could be the issue. I'm a naive in Silverlight.
Did you Register the MIME Types on IIS?
Register the MIME type for file extension .XAP and .XAML in IIS
Extension MIME Type .xaml application/xaml+xml .xap application/x-silverlight-app
精彩评论