Detect Smart Phone or PDA version in a Web Page
I wanted to know weather the device is a smart phone or PDA while connecting to Web Page." Can anyone help with this....??
Printable View
Detect Smart Phone or PDA version in a Web Page
I wanted to know weather the device is a smart phone or PDA while connecting to Web Page." Can anyone help with this....??
Try this Hope this Helps :
Code:Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim Browser_obj As System.Web.Mobile.MobileCapabilities = CType(Request.Browser, System.Web.Mobile.MobileCapabilities)
If Browser_obj.Browser = "Pocket IE" Then
Label1.Text = " is a Pocket PC"
ElseIf Browser_obj.Browser = "IE" Then
Label1.Text = "Internet Explorer"
ElseIf Browser_obj.Browser = "Phone.com" Then
Label1.Text = "is a Openwave"
End If
End If
End Sub
Excluding Unknown Browsers
If you provide only evidence for specific browsers in the detection logic, your site will not be usable if a visitor uses a different browser. Consider the following example:
Note like the precedence example of style only for Internet Explorer and Navigator 4 and also then only if the visitor has activated the support Javascript in own browser. The customers of Netscape 6, Netscape 7, CompuServe 7, Mozilla, Work will not be in a position to visualizing the site correctly.Code:// WRONG Application - not to use!
if (document.all)
{
// Internet Explorer
document.write('<link rel="stylesheet" type="text/css" src="style-ie.css">');
}
else if (document.layers)
{
document.write('<link rel="stylesheet" type="text/css" src="style-nn.css">');
}
Unidentifying Browsers
Authors of a general failure of the network will be formed to assume that when a browser is not Netscape Navigator 4, Internet Explorer, it should be and vice versa. For example:
Mark on how the above example assumed that each use browser which Internet Explorer is not navigator 4 and tried layers.Code:// WRONG Application - not to use!
if (document.all)
{
// Internet Explorer
elm = document.all['menu'];
}
else
{
// Assume Navigator 4
elm = document.layers['menu'];
}
Try it will work Definitely :
Code:if (Request.Headers["User-Agent"] != null &&
(Request.Browser["IsMobileDevice"] == "true"
|| Request.Browser["BlackBerry"] == "true" ||
Request.UserAgent.ToUpper().Contains("MIDP")
|| Request.UserAgent.ToUpper().Contains("CLDC"))
|| Request.UserAgent.ToLower().Contains("iphone"))