Environment Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides properties to determine what runtime environment was used to open the form template.
public ref class Environment abstract
public abstract class Environment
type Environment = class
Public MustInherit Class Environment
- Inheritance
-
Environment
Examples
In the following example, a basic pattern is shown for checking the values of IsBrowser and IsMobile properties to conditionally run code depending on which environment and program was used to open the form.
if (this.Environment.IsBrowser)
{
// Code to run if form is open in a Web browser.
}
else if (this.Environment.IsMobile)
{
// Code to run if form is open in a mobile browser.
}
else
{
// Code to run if form is open in the InfoPath editor.
}
If (Me.Environment.IsBrowser) Then
' Code to run if form is open in a Web browser.
ElseIf (Me.Environment.IsMobile) Then
' Code to run if form is open in a mobile browser.
Else
' Code to run if form is open in the InfoPath application.
End If
Remarks
Use the Environment property of the XmlForm class to access an Environment object you can use determine which runtime environment and program was used to open the form template for editing.
The Environment class provides the IsBrowser and IsMobile properties which enable you to determine what editing environment was used to open a form template. If both properties return false, the form template was opened in Microsoft InfoPath. If either property returns true, the form template was opened from an appropriately configured document library on Microsoft SharePoint Server 2010 running InfoPath Forms Services in the program for the corresponding property: a Web browser (IsBrowser property) or a mobile browser (IsMobile property).
Constructors
Environment() |
Properties
IsBrowser |
Gets whether the form template was opened from InfoPath Forms Services in a Web browser. |
IsMobile |
Gets whether the form template was opened from InfoPath Forms Services in a browser on a mobile device. |