.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Detect Browser Screen Size??

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Hi Everyone,  I need to detect the size of the user's screen for mobile devices (especially the BlackBerry). I've read a lot of pages that seem to refer me to the Request.Browser object, but I'm finding that this object doesn't have the correct values. For example, I have a BlackBerry and when I use the Request.Browser to get the screen size, it tells me it is 640x480. Well, I know it's not that big since an image of 300px wide just barely fits. Also, when I run on my desktop browser, it also says my screen is 640x480. I can assure you, it is not 640x480! ha!

  How does anyone reliably get the browser's screen size?? Do I have to revert to some kind of JavaScript? If so, where can I read more about it? Will it be any more reliable? Someone must have an idea about this. Thanks in advance!!

View Complete Post

More Related Resource Links

Obtain mobile device screen size



I am trying to get the screenHeight and width:


 // Get MobileCapabilities from current Request.Browser
        MobileCapabilities currentCapabilities = (MobileCapabilities)Request.Browser;
        // get a property of the  browser 
        Response.Write(currentCapabilities.ScreenPixelsHeight +  " <br>");
        Response.Write(currentCapabilities.ScreenPixelsWidth  + " <br>");


 but this is always show that the Height is 480 & the width is 640

I am trying on HTC with Opera Mobile 9.5

Any Advice?

How to detect and prevent new browser instance


Hi Folks,

I have a problem w/ a web app which is probably fairly common, but I cannot find any solutions anywhere. Hopefully someone will have an idea.

The web app in question provides a UI for editing a client (in the business sense, not the browser sense), identified by a ClientID.  I store the ClientID in Session, which gets passed from page to page, along with a number of other pieces of data in Session.  Works great.

The problem is that if the user opens a new browser window using Ctrl N or File->New Window (in IE), the new window comes up with the same page as the current page, with the same session info. Then if the user navigates to a different client in the 2nd window, the ClientID in session refers to the new client. If they go back to the original browser window and save, the original client gets saved using the 2nd ClientID, and all hell breaks loose, because now the data from the two jobs are intertwined.

I have enabled trace and verified that the new browser window uses the same SessionID as the original.  If an entirely new instance of IE is opened, it has a different SessionID, so is not a problem.  I have not yet investigated other browsers, such as Chrome or Firefox.

Is there any way to determine if a browser instance is opened for a web app which is already open in

Need more font size options in browser edit mode

Is there a way to have a different font size other than the drop down menu of Editing Tools > Format Text of: 8, 10, 12, 18, 24, 36, 48, 72 pt ?   As a designer, I feel handcuffed with just these options. 

BitmapImage detect image size before calling EndInit()

Hi, I'm using the following converter to create the thumbnails images: public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { BitmapImage bi = new BitmapImage(); string FilePath = value as string; if (null != FilePath) { bi.BeginInit(); bi.DecodePixelHeight = 80; bi.CacheOption = BitmapCacheOption.OnLoad; bi.CreateOptions = BitmapCreateOptions.DelayCreation; bi.UriSource = new Uri(FilePath); bi.EndInit(); } if (bi.CanFreeze) { bi.Freeze(); } return bi; } catch { return DependencyProperty.UnsetValue; } }   The problem is that I want to detect the image file height before generating the actual BitmapImage. In other words I need something like this:   bi.BeginInit(); if(bi.Height > 80) { bi.DecodePixelHeight = 80; } bi.CacheOption = BitmapCacheOption.OnLoad; bi.CreateOptions = BitmapCreateOptions.DelayCreation; bi.UriSource = new Uri(FilePath); bi.EndInit();   Which of cause can't be done before the EndInit() has been called. Is there is any other solution that doesn’t require creating some sort of Image class and loading the image file into it. The problem is that I'm expecting to hav

SSRS BUG? When a FontStyle expression is used in a report, the Browser Text Size setting overrides t

I have created a report that has the same font size for all the sections in the report. Some sections' fields use a FontStyle expression that changes the FontStyle between Normal and Italics conditionally. I run the report through the reportserver interface and the report looks fine. I run the report through the ReportViewer control and the the fields which use the FontStyle formula are overridden by the Browser's Page Text Size. Also, when I look at the inline HTML Style that's generated, the fields with the formula don't have a style, they are blank, while the fields with without a FontStyle expression have an inline HTML Style generated. And this is probably why the browser text size setting can override. This seems like a ReportViewer HTML render bug... Or is there a way around it??

how to fix the height of the table to be same as the screen size?

hi,iam trying to have my web page design inside a table that fills the screen in width and height.i tried like this<table  border="0" cellspacing="0" cellpadding="0"                         style="width:100%; height:100%; margin-right: 0px; margin-left:0;margin-top:0; margin-bottom: 0px;">            <tr> etc...the table width is filling 100 % but the height is not expanding to the bottom of the screen.my aim is to have a column in the table that looks like a left pane and it will contains dynamically added controls so if there is controls or no the column will have the height of the screenthanks for the help

Make font size relative to container or browser size?


Is there any way to make font size a percentage of the size of either the parent container or the browser window viewport? Having fixed-width fonts inside variable-width containers is causing the layout to break.

Detect what kind of mobile/browser is accessing a webpage



Right now, I have designed my page that works great with an iphone screen, with the help of this meta tag:

<meta id="ctl00_viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">

Problem is, how do i detect what kind of phone that are acessing my page, and afterwards change this meta tag to fit it to that phone?

Thanks alot :)

How do I detect if a browser is from a mobile device?



I have an existing ASP.NET (VB.NET) created with Visual Web Developer Express 2008.

I have recently created new pages for iPhone and other mobile devices: www.mysite.com/mobile/home

What's the best way to check if the user is using a mobile device and so redirect them to the URL above?


Code to detect monitor size

How to detect monitor size(i.e. 15 inch, 18 inch, 24 inch, etc) from C#.Net 2005 Windows Application.

hide webpart if screen size lower than 1280

Hello all,

I am using a webpart zone control and I need to set it to visible if the screen resolution of the user is nore then 1280 pixels.

How do I do that?


How to detect user's screen resolution


Hello all,

I am using a asp:Label control and I need to set it to visible if the screen resolution of the user is nore then 1000 pixels.

How do I do that?


Adjust application window size per screen resolution on different computers


I have built an  application which calls two dialog boxes defined in a .rc file.

When this application was run on a computer with a screen resolution of 600 x 800

the dialog boxes were not fully displayed.  How can I automatically adjust for different screen resolutions?

Snap It! - How to take screen shot using .Net

We all would have used snap shots (screen shots) to illustrate bugs or behavior or something that others could understand by seeing them. For taking snap shots we just hit the "Print Screen" key and copy it to Ms Paint and save it. Ever wondered how to programmatically take a snap shot? Then this article is for you.

How to detect and avoid memory and resources leaks in .NET application

Despite what a lot of people believe, it's easy to introduce memory and resources leaks in .NET applications. The Garbage Collector, or GC for close friends, is not a magician who would completely relieve you from taking care of your memory and resources consumption.

I'll explain in this article why memory leaks exist in .NET and how to avoid them. Don't worry, I won't focus here on the inner workings of the garbage collector and other advanced characteristics of memory and resources management in .NET.

Reduce ASP.NET Page size and complexity using JQuery

This is my first post on asp.net blog. ASP.NET Ajax and JQuery are two different ajax framework. In this post I will show, how we can enhance gridview using ASP.NET Ajax and JQuery. I also compare the implementation of these frameworks. In next posts i will explain more about JQuery and ASP.NET Ajax and also tell you "How to combine the power of both framework". My Future post will related to ASP.NET and related frameworks.

PDA Keyboard v1.0 Light Edition - Full Screen Keyboard

The default keypad on Windows Mobile is not at all finger friendly, there is no way you can use it with your fingers. I have trouble using the stylus with it too. But there are many freeware option available to make the SIP ( Software Input Panel - check the Glossary ) finger friendly. Some of these are HTC Diamond keyboard, Blimkeys, PocketCM Keyboard and then now we have PDA Keyboard v1.0 Light Edition from pdamedia.biz. When you hit the blue button it goes into fullscreen mode , then you can use both your hands for typing.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend