Home All Groups Group Topic Archive Search About

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

Author
9 Mar 2006 6:38 PM
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 rick1r***@gmail.com would be much appreciate also.

Thanks in advance.

Author
9 Mar 2006 6:44 PM
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 rick1r***@gmail.com 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
Are all your drivers up to date? click for free checkup

Author
9 Mar 2006 6:56 PM
Tom Porterfield
>> 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??!?!?!
>
> 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.
--
Tom Porterfield
Author
9 Mar 2006 7:14 PM
Lebesgue
Maybe we would see he is talking about web application if he wasn't
screaming all around the relevant text...

Show quoteHide quote
"Tom Porterfield" <tppor***@mvps.org> wrote in message
news:uzt30s6QGHA.4952@TK2MSFTNGP09.phx.gbl...
>>> 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??!?!?!
>>
>> 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.
> --
> Tom Porterfield
Author
9 Mar 2006 7:17 PM
Michael Nemtsev
Hello Tom,

Sure, my fault, missed web content

there is a sample for ASP.net

>>> 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??!?!?!
>>>
>> What kind of resolution, there are several one :)
>>
>> See
>>
>> SystemInformation.PrimaryMonitorSize
>> SystemInformation.WorkingArea
>> SystemInformation.VirtualScreen
>> Screen.PrimaryScreen.Bounds
>> Screen.PrimaryScreen.WorkingArea
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
Author
9 Mar 2006 6:53 PM
Lebesgue
There is class named Screen which may help you.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsscreenmemberstopic.asp
Calm down a little bit, man

Show quoteHide quote
"ManwSloHand" <manwsloh***@yahoo.com> wrote in message
news:1141929523.438768.121150@i39g2000cwa.googlegroups.com...
> 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 rick1r***@gmail.com would be much appreciate also.
>
> Thanks in advance.
>
Author
9 Mar 2006 9:44 PM
ManwSloHand
> There is class named Screen which may help you.
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre...
> Calm down a little bit, man

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?
Author
9 Mar 2006 9:36 PM
John Timney ( MVP )
you can use javascripts screen.width and screen.height and pass the values
to your app

http://www.devcity.net/Articles/64/1/screenresolution.aspx

or

http://www.quepublishing.com/articles/article.asp?p=28493&seqNum=6&rl=1

both provide good examples

--
Regards

John Timney
Microsoft MVP

Show quoteHide quote
"ManwSloHand" <manwsloh***@yahoo.com> wrote in message
news:1141929523.438768.121150@i39g2000cwa.googlegroups.com...
> 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 rick1r***@gmail.com would be much appreciate also.
>
> Thanks in advance.
>
Author
9 Mar 2006 9:41 PM
JR
I noticed both of the previous replies were for windows forms and you are
asking for web application so try this
http://www.devcity.net/Articles/64/1/screenresolution.aspx

HTH
JR

Show quoteHide quote
"ManwSloHand" <manwsloh***@yahoo.com> wrote in message
news:1141929523.438768.121150@i39g2000cwa.googlegroups.com...
> 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 rick1r***@gmail.com would be much appreciate also.
>
> Thanks in advance.
>
Author
9 Mar 2006 9:57 PM
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.
Author
10 Mar 2006 3:59 AM
Tom Porterfield
On 9 Mar 2006 13:57:24 -0800, ManwSloHand wrote:

> 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.
--
Tom Porterfield

Bookmark and Share