As we are developing applications it can be accessible from any where and any device including computers, mobiles, iphone, ipod or whatever. But, the important thing is UI. A web site how it looks like on computers is completely different from the mobile. So, we need to detect the user agent or the client who requested the site. So, if request from computer browsers then we don't need to anything as this is the default type. Whereas the request from the mobile phones then we need to render different UI. So, this post will explains that.
Detect request from iPhone in ASP.NET [C#]:
if(HttpContext.Current.Request.UserAgent.ToLower.Contains("iphone"))
{
//iPhone is the requested client. Write logic here.
}
else
{
//Normal browsers [from computers] requested.
}Detect the iPhone request in Java script:
if (navigator.userAgent.match(/iPhone/i)
So, depends on the client we will write the corresponding logic in the specific block to switch UI. Hope this helps.
No comments:
Post a Comment