Did You Know... There are two ways to pass data to your Silverlight 1.0 control on creation
CreateSilverlight() and its wrapper, CreateSilverlightEx() both take an optional sixth and seventh parameter. The sixth, initParam takes a string parameter that you can easily fetch in your javascript code; it becomes an attribute of the Silverlight control (plugin) itself.
For example, you can modify the starter sample that Visual Studio 2008 creates for you by adding this line to Default.html.js:
The sixth parameter must be a string. How you use that string is entirely up to you. . To see using this parameter at work, modify HandleMouseUp in Scene.xaml.js as follows:
handleMouseUp: function(sender, eventArgs)
{
var mouseUpAnimation = sender.findName("mouseUp");
mouseUpAnimation.begin();
var paramValue = this.plugIn.initParams;
alert(paramValue);
}
In this case, you're accessing the value of the parameter passed in by the user, and placing it into the alert box when the button is clicked.