InitParams Property

Gets or sets an optional set of user-defined initialization parameters.

Scripting (Instantiation)
Silverlight.CreateObject(,,,,,initParams)

-or-

Silverlight.CreateObjectEx({initparams:initParams})
Scripting (Runtime)
value = silverlightObject.InitParams

Property Value

string

Specifies a string that represents a set of user-defined initialization parameters. The string format of the value is user-defined.

This property is settable only as an initialization parameter, and is read-only for scripting thereafter. The default value is null.

Remarks

The InitParams property cannot be set after initialization. The initParams initialization parameter specifies user-defined parameter values. These parameters values can be retrieved at run time by accessing the plug-in's InitParams property. InitParams provides a convenient way to pass your own string values from the HTML DOM into the Silverlight object model. For more information on how this property is set during plug-in initialization, see Instantiating a Silverlight Plug-in (Using CreateSilverlight.js and Silverlight.js) or Using InitParams to Specify and Retrieve Custom Initialization Parameters.

Generally, if you have more than one string atom to pass, you would use some character (such as a comma) as a delimiter in the combined InitParams string and then split the string into atoms again from your Silverlight JavaScript code.

Examples

The following JavaScript example shows how to specify the initParams parameter value in the user-defined CreateSilverlight method in CreateSilverlight.js.

JavaScript
function createSilverlight()
{  
    Silverlight.createObject(
        "plugin.xaml",                  // Source property value.
        parentElement,                  // DOM reference to hosting DIV tag.
        "myPlugin",                    // Unique plug-in id value.
        {                               // Plug-in properties.
            width:'600',                // Width of rectangular region of plug-in in pixels.
            height:'200',               // Height of rectangular region of plug-in in pixels.
            version:'1.0'               // Plug-in version to use.
        },
        { },                            // No events defined -- use empty list.
        "param1, param2");              // InitParams property value.
}

To access the value of the initParams initialization parameter values at run time, use the InitParams property of the plug-in. The following JavaScript example shows how to retrieve the parameter values using the InitParams property.

JavaScript
function onLoaded(sender, eventArgs)
{
    // Retrieve a reference to the plug-in.
    var plugin = sender.getHost();
    // Retrieve the InitParams value and split comma-delimited string.
    var params = plugin.initParams.split(",");
    // Display the parameter values.
    var msg = "Params: ";
    for (var i = 0; i < params.length; i++)
    {
        msg += params[i] + " ";
    }
    alert(msg);
}

Applies To

Silverlight Plug-in

See Also

Instantiating a Silverlight Plug-in (Using CreateSilverlight.js and Silverlight.js)
Using InitParams to Specify and Retrieve Custom Initialization Parameters