News:

Build a stunning handcrafted website with IT Acumens

Main Menu

Passing Initialization Data Across Domains

Started by thiruvasagamani, Jan 26, 2009, 03:07 PM

Previous topic - Next topic

thiruvasagamani

Passing Initialization Data Across Domains

Once you have uploaded your Silverlightâ„¢ application to Silverlight Streaming, you invoke the application from a Web page that's running in a different domain. Because the Web page and the Silverlight application are in different domains, programmatic interaction between the two is limited to passing initialization strings at the time the application is loaded.
Setting the initParams Attribute

You can pass initialization data to the Silverlight application via the initParams attribute of the Silverlight Streaming control. Set the initParams attribute by specifying one or more key/value pairs, separated by commas, as shown in the following example.
Copy Code

<devlive:slscontrol
    silverlightVersion="1.0"
    src="/32/HelloWorld/"
    installationMode="popup"
    initParams="myKey1=textString,myKey2=dateString">
</devlive:slscontrol>


To set the value of initParams programmatically at runtime, use the Silverlight Streaming control's onInit event to call a function that sets the attribute's value. This is shown in the following example.
Copy Code

<html xmlns:devlive="http://dev.live.com">
    <head>
        <script type="text/javascript" src="http://controls.services.live.com/scripts/base/v0.3/live.js">
        </script>
        <script type="text/javascript" src="http://controls.services.live.com/scripts/base/v0.3/controls.js"></script>
    </head>
    <body>
        <script type="text/javascript">
        function OnInit()
        {
             document.getElementById('c').setAttribute("initParams", "x=1;y=2");

        }
        </script>
        <devlive:slscontrol
            id="c"
            onInit="OnInit"
            silverlightVersion="1.0"
            src="/32/MySilverlightApp/"
            installationMode="popup">
        </devlive:slscontrol>
    </body>
</html>

Thiruvasakamani Karnan