client screen size and MS suggestion

G

Guest

I think I placed this in the wrong news group so I'm moving it here.

Suggestion to Microsoft make the categories more clear and make better
sense. ASP.NET should be its own group, why bury under Framework. And I see
others doing the same mis-posting to dotnet.general which appears to be
gearded more towards windows applications. What are General and Framework for
options under .NET Development!

After exhausting my search on the MS website, I can't find a straight answer.
I find it hard to believe that MS left our something so useful in ASP.NET as
screen resolution detection.

Problem:
I would like to detect, get values for, the screen resolution in px but in a
code behind. Is this possible?

There is a System.Windows.Forms.Screen class for the Windows client side,
why are there none for browser/ASP.NET client?

thank you.
 
B

bruce barker

the easy answer is the browser does not send the client screen resolution
and the server code has no access to the client machine. you can write
javascript to capture it, and post the values with a sniffer page (usually
the entry page of the site). while you can control general layout this way,
there is no way for the server to know the size of strings in pixels,
because it will not know the fonts/sizes actually used by the client
browser. also the size of the browser window is more important than the
screen resolution, and the user can easily change this.

add this to every page, and you can know the resolution on every postback.
(save it in session for GET renders)

<input type=hidden name=screenX id=screenX runat=server>
<input type=hidden name=screenY id=screenY runat=server>
<script>
document.getElementById('screenX')=window.screen.width;
document.getElementById('screenY')=window.screen.height;
</script>

-- bruce (sqlwork.com)


| I think I placed this in the wrong news group so I'm moving it here.
|
| Suggestion to Microsoft make the categories more clear and make better
| sense. ASP.NET should be its own group, why bury under Framework. And I
see
| others doing the same mis-posting to dotnet.general which appears to be
| gearded more towards windows applications. What are General and Framework
for
| options under .NET Development!
|
| After exhausting my search on the MS website, I can't find a straight
answer.
| I find it hard to believe that MS left our something so useful in ASP.NET
as
| screen resolution detection.
|
| Problem:
| I would like to detect, get values for, the screen resolution in px but in
a
| code behind. Is this possible?
|
| There is a System.Windows.Forms.Screen class for the Windows client side,
| why are there none for browser/ASP.NET client?
|
| thank you.
|
 
P

Patrice

Please avoid to create multiple threads for the same subject.

Keep in mind that ASP.NET is all about server side. There is no HTTP/HTML
mecanism that automagically sends this info to the server. You'll have to
use js to find out those values and post it yourself.

The whole story may also help (if this is to position elements, you may want
to see if HTML doesn't allow to "autoplace" those element such as just by
centering)

Patrice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top