How the devil do I get screen resolutions??!!?

M

ManwSloHand

ARGH! I have a c#.net web application. I need to retrieve screen height
and width into a variable. I know this is incredibly stupid but HOW THE
HECK DO I DO IT??!?!?!

A copy to (e-mail address removed) would be much appreciate also.

Thanks in advance.
 
M

Michael Nemtsev

Hello ManwSloHand,

What kind of resolution, there are several one :)

See

SystemInformation.PrimaryMonitorSize
SystemInformation.WorkingArea
SystemInformation.VirtualScreen
Screen.PrimaryScreen.Bounds
Screen.PrimaryScreen.WorkingArea

M> ARGH! I have a c#.net web application. I need to retrieve screen
M> height and width into a variable. I know this is incredibly stupid
M> but HOW THE HECK DO I DO IT??!?!?!
M>
M> A copy to (e-mail address removed) would be much appreciate also.
M>
M> Thanks in advance.
M>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
T

Tom Porterfield

ARGH! I have a c#.net web application. I need to retrieve screen
What kind of resolution, there are several one :)

See

SystemInformation.PrimaryMonitorSize
SystemInformation.WorkingArea
SystemInformation.VirtualScreen
Screen.PrimaryScreen.Bounds
Screen.PrimaryScreen.WorkingArea

I doubt any of that is what he wants since that would get the resolution of
the server you are running on and I would expect he wants the cleint
resolution (note he did say web application). This would need to be done in
client side script that populates variables that would then be posted back
to the server for reading. The values to query in javascript would be
window.screen.width and window.screen.height.
 
L

Lebesgue

Maybe we would see he is talking about web application if he wasn't
screaming all around the relevant text...
 
M

Michael Nemtsev

Hello Tom,

Sure, my fault, missed web content

there is a sample for ASP.net
TP> I doubt any of that is what he wants since that would get the
TP> resolution of the server you are running on and I would expect he
TP> wants the cleint resolution (note he did say web application). This
TP> would need to be done in client side script that populates variables
TP> that would then be posted back to the server for reading. The
TP> values to query in javascript would be window.screen.width and
TP> window.screen.height.
TP>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
M

ManwSloHand

There is class named Screen which may help you.

Sorry about the yelling guys. This should be simple but I've been
beating my head against a wall for 4 hours now and can't get it to
work. I can't find how to get the Screen class included into my project
(no using). Also haven't been able to get SystemInformation to work in
a web application either.

I've done it using Javascript in my ASP apps. Had to have JV write a
cookie, then read the cookie from within the ASP script. That might
work (I guess) here but just seems like .Net should've dealt with a
well-known problem like this.

Any more suggestions?
 
M

ManwSloHand

I noticed both of the previous replies were for windows forms and you are
asking for web application so try this

That's what I'm afraid of. I've been pounding a co-worker of mine with
how great .Net tools are and how un-stable Javascript is. Now I've
gotta eat crow and go back and say "hey, let's use javascript!". Ugh.
Is there a way to use javascript in my page behind code (html) to stick
the resolution into a form control (label or textbox)? I'm thinking I
could grab it in code. BTW, what I'm ultimately after is that I want to
store a database record to record the user's screen res, browser type,
and IP for later analysis.

Thanks again.
 
T

Tom Porterfield

That's what I'm afraid of. I've been pounding a co-worker of mine with
how great .Net tools are and how un-stable Javascript is. Now I've
gotta eat crow and go back and say "hey, let's use javascript!".

But client side you are still in a browser, so you are limited to what you
can do within a browser window. Now I suppose you could write a custom
browser control in .NET, embed that in your web page and then use the .NET
code to get the information. This would require the .NET framework be
installed on any client visiting your website. Seems like a bad way to go
when you can get the same info with a couple of lines of javascript. The
key is knowing the appropriate tool to use for each given situation.
 

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

Top