Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
CheckBrowserCaps()
End Sub
Function CheckBrowserCaps()
Dim labelText As String = ""
Dim myBrowserCaps As System.Web.HttpBrowserCapabilities = Request.Browser
If (CType(myBrowserCaps, System.Web.Configuration.HttpCapabilitiesBase)).IsMobileDevice Then
labelText = "Browser is a mobile device."
Else
labelText = "Browser is not a mobile device."
End If
Label1.Text = labelText
End Function 'CheckBrowserCaps
Code (C#)
void Page_Load(Object Sender, EventArgs e)
{
CheckBrowserCaps();
}
void CheckBrowserCaps()
{
String labelText = "";
System.Web.HttpBrowserCapabilities myBrowserCaps = Request.Browser;
if (((System.Web.Configuration.HttpCapabilitiesBase)myBrowserCaps).IsMobileDevice)
{
labelText = "Browser is a mobile device.";
}
else
{
labelText = "Browser is not a mobile device.";
}
Label1.Text = labelText;
}