Original article: http://www.limingchstudio.com/2009/07/silverlight-3-sdk-aspnet-mediaplayer.htmlSilverlight 2 SDK (installed with Silverlight 2 tools for Visual Studio 2008 SP1) provides 2 Silverlight ASP. NET Server controls:
· ASP. NET mediaplayer Control
Integrate audio (WMA) and video (WMV) media sources into Web ApplicationsProgram.
· ASP. NET Silverlight Control
With the scriptmanager control, you can embed a XAML application on a web page.
Install the Silverlight 3 SDK (when Silverlight 3 tools for Visual Studio 2008 SP1 is installed)The precedingSilverlight ASP. NETServer ControlIn other words, when you have not installed the Visual Studio 2008 SP1 integrated development environment of Silverlight 2 SDK, open the. aspx web page and expandToolbox 」And will not see「Silverlgiht」This index volume label (if you install both the Silverlight 2 SDK and the Silverlight 3 SDK, you will see this index volume label ). To upgrade the existing Silverlight 2 solution to Silverlight 3 or use these two controls in Silverlight 3, download asp from msdn code Gallery. net server controls for Silverlight samples (the system. web. silverlight. the current dll version is 3.0.40210.0 ).
After downloading, uncompress the compressed file andSystem. Web. Silverlight. dllCopy toBinDirectory. Right-clickSolution Manager 」And then press"Property page 」Command, and then press「 Reference 」Node to copySystem. Web. Silverlight. dllAdd reference.
Do not forget to specify the correspondence between the front-end and the namespace in the web. config file, or directly use@ RegisterAs shown in the following figure:@ RegisterIndicator Setting:
<% @ Register Assembly = "system. Web. Silverlight"
Namespace = "system. Web. UI. silverlightcontrols" tagprefix = "asp" %>
If your solution is upgraded from Silverlight 2 or Silverlight 3 beta, we recommend that you replace the web page that originally used the ASP. NET Silverlight control<Object>Mark to embed and set the Silverlight plug-in through the HTML syntax. The most important thing is that this method can be compatible with all browsers supported by Silverlight. For example, the original webpage ProgramCodeIs:
<
ASP: Silverlight
Runat
=
"Server"
Width
=
"100%"
Height
=
"100%"
Source
=
"~ /Clientbin/limingstudio. xap"
Scalemode
=
"Stretch"
Minimumversion
=
"2.0.0.0"
Onclientpluginloaded
=
"OnLoad"
/>
Changed:
<
Script
Type
=
"Text/JavaScript"
>
Function handleresize (OBJ ){
//
Write the code for processing the silverlgiht plug-in size here
}
Function onload (OBJ ){
//
Write the program code for loading the silverlgiht plug-in here
}
</
Script
>
...
<
Object
Data
=
"Data: Application/x-silverlight-2 ,"
Type
=
"Application/x-silverlight-2"
Width
=
"100%"
Height
=
"100%"
>
<
Param
Name
=
"Source"
Value
=
"/Clientbin/limingstudio. xap"
/>
<
Param
Name
=
"Onresize"
Value
=
"Handleresize"
/>
<
Param
Name
=
"Minruntimeversion"
Value
=
"3.0.40624.0"
/>
<
Param
Name
=
"OnLoad"
Value
=
"OnLoad"
/>
</
Object
>
The preceding parameters are briefly described as follows:
· UseDataAttribute can avoid low performance in some browsers. Remind everyone,The comma before the end double quotation marks is a part of the property value, representing2The data parameter value is null..
·TypeThe attribute is used to identify the Silverlight plug-in and the required version of The Silverlight MIME type.
· AsWidthAndHeightThis attribute is required for cross-browser compatibility. It is used to specify a fixed pixel value or percentage relative to the width and height of the ancestor element. If the relative size is used, you can use the handleresize function in the preceding program code to handle the content. resized event, so that when the plug-in size changes, you can handle it as appropriate.
·ParamProjectSourceIs a necessary property setting, which indicates the location and name of the application file. We usually use relative paths to specify the. xap application suite.
·ParamProjectMinruntimeversionUsed to specify the minimum version of The Silverlight plug-in required for executing the Silverlight application.
Finally, do not forgetSilverlight. jsFiles (the default directory is c: \ Program Files \ microsoft sdks \ Silverlight \ V3.0 \ tools) are copied to the ASP. NET Website project and referenced on the webpage.