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.
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):
@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"
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.
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.
精彩评论