Silverlight Hosting The Silverlight 2 browser control is configurable with any web server-side technology such as ASP. NET, classic ASP, JSP, Ruby, or PHP because it is configured using the standard HTML tag . When you create a new Silverlight application, you have the option of having the project wizard create two test pages for the new Silverlight application, an .aspx test page, and an .html test page . These pages serve as a starting point for configuring the Silverlight control. Here is a sample tag from the HTML page:Note: The Sample tag code is present in the attachment because the browser was interpreting the tag so I moved it to attachment. Here is a sample tag from the ASPX page: Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/MySilverlightApp.xap " MinimumVersion="2.0.31005.0" Width="100%" Height="100%" InitParameters="firstPage=Page"
Note: Removed the "<" and "ASP:" from the start and "/>" from the end because the browser was interpreting the tag The typical page includes a few CSS styles and a JavaScript function named onSilverlightError as well as a script include for Silverlight.js. The onSilverlightError function provides reporting for errors that are not handled within the Silverlight application. There are some errors that cannot be handled in the Silverlight application, such as problems downloading the application .xap file. Unhandled errors in the Silverlight application will bubble up to the Silverlight browser control and be reported to the user via the onSilverlightError function or any custom JavaScript function written by the developer. By default, the onSilverlightError function is wired to the Silverlight control in the following line of code: param name="onerror" value="onSilverlightError"
Note: Removed the "<" and "/>" from the start and end because the browser was interpreting the tag The onSilverlightError function need not be used as it is. It can be customized, or any existing JavaScript error-handling routines that are part of an existing application can be used.Caution: Any errors bubbled up to the onSilverlightError function will cause the Silverlight application to stop working. Try to handle all errors that can be handled within the Silverlight application. Only catastrophic errors should be allowed to bubble up. The tag includes several configurable attributes; a key attribute is type, which determines the version of Silverlight that is needed by the application. For the final release version of Silverlight 2, type is set to "application/x-silverlight-2". Changing this value is part of the steps required to migrate from one version of Silverlight to the next. Within the tag are tags that define parameters configured for the instance of the Silverlight browser plug-in. The one mandatory parameter is source, which defines the location of the application .xap file, or optionally, it can point to inline XAML if the Silverlight unmanaged JavaScript programming model is being used. Recommended events are onError and onResize. As mentioned earlier, by default the onError parameter is set to the onSilverlightError function to report unhandled exceptions as well as runtime errors that occur at the plug-in level in the HTML page. Other parameters that are available are:AutoUpgrade = Allows the developer to control whether an end user's Silverlight plug-in should be upgraded. The end user can still opt out even if the option is set to true.Background = Sets the background color for the Silverlight 2 plug-in behind any Silver-light application content that renders to the content area but in front of HTML. This property defaults to null.enableFramerateCounter = Displays the current frame rate in the browser's status bar in Internet Explorer on Windows. The default is false.enableHtmlAccess = Enables or disables access to the web browser DOM. The default value is false. Set it to true if you want to access the web page from Silverlight. initParams = Comma-delimited string of initialization information in the form of key1=value1, key2=value2, and so on that can be accessed within Silverlight using managed code. minRuntimeVersion = Specifies the minimum Silverlight 2 runtime version required by the Silverlight application.maxFramerate = Specifies the upper limit on the frame rate for rendering content, with a default value of 60 frames per second.onLoad = Set to a JavaScript function that fires after the Silverlight plug-in is instantiated and the XAML Visual Tree is loaded.splashScreenSource = Set to the value of a .xaml file that is displayed as a splash screen while the application pointed to in the Source parameter is down-loaded. Within the tag is an HTML tag that displays the "Get Silverlight" image when the browser plug-in is not installed. Clicking the image will download the browser plug-in required by the Silverlight application.