将Silverlight 4.0与SharePoint 2007集成

时间:2010-11-08 15:08:29

标签: sharepoint silverlight-4.0 sharepoint-2007

我创建了一个简单的Sharepoint Web部件,它承载了一个silverlight应用程序。我创建了一个用户控件,它从布局路径加载usercontrol.ascx并加载它。

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);

    }
}

用户控制(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>

但是我没有在页面中呈现silverlight控件。可能是什么问题。我在Silverlight中很天真。

1 个答案:

答案 0 :(得分:1)

您是否在IIS上注册了MIME类型?

在IIS中注册文件扩展名.XAP和.XAML的MIME类型

扩展MIME类型 .xaml application / xaml + xml .xap application / x-silverlight-app