Share via

InitParams (Silverlight Plug-in Object)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets user-defined initialization parameters.


object Element

<object ...>
  <param name="initparams" value="initParamsString"/>




value = silverlightObject.InitParams;



Managed Code

Property Value

A string that represents a set of user-defined initialization parameters. The format of the value can be user-defined. The default value is null or an empty string.


The InitParams property is write-once during instantiation and read-only at run time. It cannot be set after initialization. The InitParams initialization parameter specifies user-defined parameter values when you create an instance of the Silverlight plug-in in an HTML page. InitParams provides a convenient way to pass custom string values from the HTML Document Object Model (DOM) to the Silverlight programming model.

Generally, if you have more than one string value to pass, you use a comma as a delimiter in the InitParams string. In the JavaScript API, using the general string functions for JavaScript, you can parse and split the string into separate parameters. If you use managed code, the StartupEventArgs.InitParams object in which the property value is passed expects a particular format for the input string.

The InitParams values are provided as event data for the Startup event, and also as the InitParams property of SilverlightHost. The property is useful if you did not handle Startup, however you should make sure you are accessing the property at a point in application lifetime when the parameters are available (which is after Startup). In either the event data or the property, the original InitParams string is redefined as a dictionary. To be processed correctly into a dictionary, your string must have key-value pairs with an equals sign between key and value. For more than one key-value pair, use commas as delimiters between key=value pairs. For details, see StartupEventArgs.InitParams.

Characters that are common in a URL (for example : (colon) / (forward slash) ? (question mark) # (hash sign)) can be passed to InitParams without requiring any additional escaping. = (equals sign) can also be part of a URL or any other string atom passed as InitParams, because the InitParams parse logic does not treat = as being the key/value delimiter unless a preceding comma initiates a new sequence. However, a comma character itself is problematic, because it is not possible to escape it to be ignored by the InitParams parse logic. If you absolutely need to pass a literal comma as part of a string, it may be necessary to devise your own encoding scheme that uses some token to represent a comma, and use your own decoding logic such as a String.Replace call on the passed string.