How to obtain Silverlight version information, OS information, and browser information in Silverlight Application

Source: Internet
Author: User

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.