.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 »

  1. I am looking for the same exact functionality … I can’t find the equivalent of document.body.clientWidth from javascript for VB… u would think it would have been the screenpixelheight u mentioned but no …

    Comment by Tommy | October 7, 2009 | Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: