Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-06-2009
Member
 
Join Date: Mar 2009
Posts: 37
.Net Detect Smartphone

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....??
Reply With Quote
  #2  
Old 04-06-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: .Net Detect Smartphone

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
Reply With Quote
  #3  
Old 04-06-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: .Net Detect Smartphone

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:

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">');
}
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.


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:

Code:
// WRONG Application - not to use!
if (document.all)
{
  // Internet Explorer
  elm = document.all['menu'];
}
else
{
  // Assume Navigator 4
  elm = document.layers['menu'];
}
Mark on how the above example assumed that each use browser which Internet Explorer is not navigator 4 and tried layers.
Reply With Quote
  #4  
Old 04-06-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: .Net Detect Smartphone

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"))
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: ".Net Detect Smartphone"
Thread Thread Starter Forum Replies Last Post
HTC One X smartphone Miyamoto Reviews 1 08-04-2012 06:52 PM
Need a New Smartphone with HD EveryWer Portable Devices 6 23-11-2011 08:44 AM
What smartphone will be best for me? Dum Portable Devices 6 02-05-2011 07:11 AM
HTC 7 Pro Smartphone OptimuS PrimE Reviews 2 11-02-2011 07:46 PM
Smartphone vs PDA Kaddy Portable Devices 3 26-08-2009 09:53 AM


All times are GMT +5.5. The time now is 07:51 PM.