Solved

Getting Browser Window Size for ASP.NET server side code

Posted on 2009-07-01
5
1,231 Views
Last Modified: 2012-05-07
Hello,
I want to optimize the display of an ASP.NET page according to the client window area of the Browser. Is there a way to get this?

Thank you
Henri
0
Comment
Question by:htourigny
  • 4
5 Comments
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24759941
u can get the screen width and height using javascript.


<Script language="javascript">
function getScreenSize()
{
var screenheight=screen.height;
alert(screenheight);
var screenWidth=screen.width
alert(screenWidth);
}

Open in new window

0
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24759968
Sorry i didnt see you wanted Server side code

http://www.codeproject.com/KB/aspnet/detectbrowser.aspx

Another one is

 Page.Request.Browser.ScreenPixelsWidth
 Page.Request.Browser.ScreenPixelsHeight



0
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24760476
did you get it working.

Let us know if you need additional help
0
 

Author Comment

by:htourigny
ID: 24761847
Page.Request.Browser.ScreenPixelsWidth and Page.Request.Browser.ScreenPixelsHeight always give 640 x 480 and the real size is different. This is true also when request is a postback. I tried with IE 7 and IE 8
0
 
LVL 9

Accepted Solution

by:
AsishRaj earned 500 total points
ID: 24767329
The easiest way would be using Javascript because postback processing happens on server side but javascript is executed on client side.


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question