简体   繁体   English

SharePoint 2010 / Silverlight:以编程方式传递自定义参数

[英]SharePoint 2010/Silverlight: Pass custom parameters programmatically

I need to pass the current logged in user's information to a Silverlight application through SharePoint 2010 Silverlight webpart. 我需要通过SharePoint 2010 Silverlight Webpart将当前登录的用户信息传递给Silverlight应用程序。 I am familiar with the custom "initialization parameters" in the Silverlight web parts properties but that does not solve my problem because of the nature of the information. 我熟悉Silverlight Web部件属性中的自定义“初始化参数”,但是由于信息的性质,这不能解决我的问题。 The "Initialization Parameters" is fixed information and logged-in user information changes. “初始化参数”是固定的信息,已登录的用户信息会发生变化。 I need to pass parameters programmatically to the silverlight application. 我需要以编程方式将参数传递给silverlight应用程序。

Maybe someone could point to a custom implementation of Silverlight host webpart. 也许有人可以指向Silverlight宿主Webpart的自定义实现。 Any help would be much appreciated. 任何帮助将非常感激。

Thanks. 谢谢。

To pass parameters dynamically to a Silverlight application, add a visual web part to your SharePoint 2010 project. 要将参数动态传递给Silverlight应用程序,请将可视化Web部件添加到SharePoint 2010项目中。 and add the following code to the markup. 并将以下代码添加到标记中。

<asp:Panel ID="SilverlightPanel" runat="server" >
    <div id="silverlightControlHost" style="width:100%;height:150">
        <object id="SLServicesBanner"
                data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="500" height="300">
            <param name="source" value="your_xap_file_goes_here"/>
            <param name="initParams" value="<%= InitParameters %>" />
            <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&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>
        <iframe id="_sl_historyFrame" style="visibility:hidden; height:0px; width:0px; border:0px"> 
        </iframe>
    </div>
</asp:Panel>

Observer the "initParams" attribute. 观察“ initParams”属性。 You can set it up to anything from codebehind. 您可以将其设置为隐藏代码的任何内容。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM