What is Silverlight.js file?

What is Silverlight.js file? Explain with an example

Silverlight.js file is a Java Script helper file. It supports for adding a Silverlight application to a web page through Java Script. It has a number of methods defined to help with, most importantly the createObject and createObjectEx. The following are certain notable functions and event handlers :

-getSilverlight, isBrowserRestartRequired, isInstalled, onGetSilverlight, onSilverlightInstalled, WaitForInstallCompletion.

The Silverlight.js file is installed along with Silverlight 2 SDK.

Using Visual Studio 2008, one can create a quick sample project by selecting File->New Project and selecting Silverlight Application. After clicking OK, select “Automatically generate a test page to host Silverlight at build time”. Click on OK. Right click on the new project and add an HTML page.

Copy the Silverlight.js into local project directory. Define a reference to Silverlight.js like any other Java Script file:
<script type="text/javascript" src="Silverlight.js"></script>

Select createObject or createObjectEx, for creating Silverlight object.
Add the following for creating createObjectEx:
// createObjectEx, takes a single parameter of all createObject parameters enclosed in {}

Silverlight.createObjectEx = function(params)
{
   var parameters = params;
   var html = Silverlight.createObject(parameters.source, parameters.parentElement, parameters.id, parameters.properties, parameters.events, parameters.initParams, parameters.context);
   if (parameters.parentElement == null)
   {
       return html;
   }
}
What is a .xap file? - Silverlight
What is a .xap file? - A .xap file is an application package based on Silverlight which will be generated when the Silverlight project is built. This file helpful in creating heavily client based Silverlight applications...
Explain how can Silverlight use ASX files - Silverlight
An ASX file is an XML file in which media files are specified in the playlist. Using ASX files in silver is pretty simple. Assign the ‘ source’ property of a MediaElement object to the ASX file name...
Silverlight application life-cycle
Silverlight application life-cycle - The entry point of Silverlight applications is Silverlight Application class. It provides various services which is commonly needed by Silverlight application...
Post your comment