Dynamicweb 8 Documentation
DeviceDetected Field
Example 

Device detected notification. Occurs when a visitors device type and platform is detected in a pageview in the frontend.
Syntax
'Declaration
 
Public Const DeviceDetected As String
public const string DeviceDetected
Example
Overriding the device detection of DynamicwebOverriding the device detection of Dynamicweb
namespace Dynamicweb.Examples.CSharp.Notifications
{
    [Extensibility.Subscribe(Dynamicweb.Notifications.Standard.Page.DeviceDetected)]
    public class DeviceDetectedObserver : Dynamicweb.Extensibility.NotificationSubscriber
    {

        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            if (args == null)
            {
                return;
            }

            var loadedArgs = (Dynamicweb.Notifications.Standard.Page.DeviceDetectedArgs)args;

            if (loadedArgs.Device == Dynamicweb.Frontend.PageView.DeviceType.Desktop)
            {
                //No mobile device detected by Dynamicweb.

                var myOwnDeviceDetectionFoundSomething = false;

                //Utilize other detection mechanism, i.e. WURFL. I.e. Dynamicweb detection of Android tablets is not 100%.
                //myOwnDeviceDetectionFoundSomething = WurflDetection()

                //If we found something else, set the information
                if (myOwnDeviceDetectionFoundSomething)
                {
                    loadedArgs.Device = Dynamicweb.Frontend.PageView.DeviceType.Tablet;
                    loadedArgs.Platform = Dynamicweb.Frontend.PageView.PlatformType.Android;
                }

            }
        }

    }
}
Namespace Notifications
    <Extensibility.Subscribe(Global.Dynamicweb.Notifications.Standard.Page.DeviceDetected)> _
    Public Class DeviceDetectedObserver
        Inherits Global.Dynamicweb.Extensibility.NotificationSubscriber

        Public Overrides Sub OnNotify(ByVal notification As String, ByVal args As Global.Dynamicweb.Extensibility.NotificationArgs)

            If args Is Nothing Then
                Return
            End If

            Dim loadedArgs As Global.Dynamicweb.Notifications.Standard.Page.DeviceDetectedArgs = DirectCast(args, Global.Dynamicweb.Notifications.Standard.Page.DeviceDetectedArgs)

            If loadedArgs.Device = Frontend.PageView.DeviceType.Desktop Then
                'No mobile device detected by Dynamicweb.

                Dim myOwnDeviceDetectionFoundSomething As Boolean

                'Utilize other detection mechanism, i.e. WURFL. I.e. Dynamicweb detection of Android tablets is not 100%.
                'myOwnDeviceDetectionFoundSomething = WurflDetection()

                'If we found something else, set the information
                If myOwnDeviceDetectionFoundSomething Then
                    loadedArgs.Device = Frontend.PageView.DeviceType.Tablet
                    loadedArgs.Platform = Frontend.PageView.PlatformType.Android
                End If

            End If
        End Sub

    End Class
End Namespace
Remarks
The passed NotificationArgs is Standard.Page.DeviceDetectedArgs
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Standard.Page Class
Standard.Page Members

Send Feedback