.NET Discussion

.NET Issues, Problems, Code Samples, and Fixes

ASP.NET: How To Get Browser Dimensions?

I’ve run across the issue of how to pull up the browser dimensions without using javascript.  One would think that Request.Browser.ScreenPixelsHeight and .ScreenPixelsWidth would suffice, right?  Well, no. Unfortunately, this only returned 640 x 480 every time I refreshed the page in different dimensions of browser window and at different resolutions.  What exactly does this “640 x 480” actually mean? I can’t seem to put my finger on it. 

It would be nice to know (without depending on Javascript) what the user’s dimensions are for a certain image of which I want to show a blowup using the ModalPopupExtender.  As it is, since the ModalPopupExtender freezes the panel in place regardless of scrolling, if my image is too big, some browsers won’t see everything, so I would like to give users with smaller browsers a scaled-down blowup image.  I suppose a little Javascript to determine these dimensions wouldn’t hurt since they have to have it on to use the ModalPopupExtender anyways, but I try not to depend on Javascript for functionality.  Anyone have any insight?  Thanks!


August 22, 2007 Posted by | ASP.NET, Javascript, ModalPopupExtender | 1 Comment