views:

67

answers:

3

I'm creating a optimized web page for mobile devices with C#. Is there a way to offer a page for larger screens and one for smaller screens on android devices? With Apple i can differentiate between iPad and iPhone, but how can I do this with the galaxy tab or a regular android phone?

I don't want to use any javascript in this case.

A: 

I don't think that there is a way to do this without using java script. Think about how you would determine the screen resolution of a normal browser. There is not much difference to that with the android browser. It is a OS that runs on very much different devices that can not possible all be known to your application. To totally optimize your page you have to ask the client for its screen resolution.

Janusz
A: 

First of all i would suggest you you JavaScript for that as you could write you own code code to detect the screen width and height and style the page accordingly, but then again it is your choice.

There are however 2 possibilities (if you really don't want JS):

  1. @media queries to where you can state different css styles (media-dependent style sheets) that work for different screen heights, widths, resolution and even more if it is a handheld device, print, etc read http://www.w3.org/TR/css3-mediaqueries/ for general idea or Bingoogle "media queries and you will find a lot of info"

  2. second solution is http://mdbf.codeplex.com/ which apparently is going to be removed on 29 Oct. you put the downloaded file in the "App_browsers" of your ASP.NET application and you serve back to the client the tailored page to his request. You can intercept the client's browser's feature during "Pade_Load" using "Request.Browser.[feature]" where feature can be ScreenPixelsWidth/height and build your page accordingly. This is really ugly since the document is man-made and man-updated, so if a new browser/screen size shows up, someone has to put it there manually so either you have to do it yourself (or somebody else) or it is not up to date.

undertakeror
A: 

Use http://51degrees.codeplex.com it gives upto-date mobile capability information like manufacturer, model, screen height & width, image formats supported and MANY MORE

It is an ASP.NET open source module which detects mobile devices and provides auto redirection to mobile optimized pages when request is coming from mobile device. It makes use of WURFL mobile device database. For redirection there is no need to modify existing ASP.NET web application pages.

Amit Patel