Because the Silverlight ApplicationProgramYou cannot obtain the Silverlight version information in code behind. You can call js to obtain the version information. Note that the enumeration method is used to obtain the version information, if Silverlight is updated, modify JS accordingly. The procedure is as follows:
1. Obtain Silverlight version information:
1. Add in JS:
Function versiondetector (){
VaR slversion;
Try {
Try {
Var control = new activexobject ('agcontrol. agcontrol ');
If (control. isversionsupported ("4.0 "))
Slversion = 4;
Else
If (control. isversionsupported ("3.0 "))
Slversion = 3;
Else
If (control. isversionsupported ("2.0 "))
Slversion = 2;
Else
Slversion = 1;
Control = NULL;
}
Catch (e ){
VaR plugin = navigator. plugins ["Silverlight plug-in"];
If (plugin ){
If (plugin. Description = "1.0.30226.2 ")
Slversion = 2;
Else
Slversion = parseint (plugin. Description [0]);
}
Else
Slversion = 0;
}
}
Catch (e ){
Slversion = 0;
}
Var control = Document. getelementbyid ("silverlightcontrol ");
Control. content. savemanager. getsilverlightversion (slversion );
}
2. Define the savebeforesilverlightshutdown class:
[Scriptabletype]
Public class savebeforesilverlightshutdown
{
[Scriptablemember]
Public void getsilverlightversion (Object OBJ)
{
String silverlightversion = obj. tostring ();
}
}
3. register the savebeforesilverlightshutdown class in application_startup:
Htmlpage. registerscriptableobject ("savemanager", new savebeforesilverlightshutdown ());
4. Add onbeforeunload = "versiondetector ()" to <body> of Silverlight testpage ()".
Okay. Now we can get the Silverlight version information.
Ii. Obtain OS information:
Private void getoperatingsysteminfo ()
{
Platformid = environment. osversion. Platform;
Version version = environment. osversion. version;
}
3. Get the browser information:
private void getbrowserinfo ()
{< br> browserinformation = htmlpage. browserinformation;
}