473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Is there a way to detect user screen resolution in server side code?


Most of the the solution i have seen was throught javascript.
Many thanks in advance
JB
Nov 19 '05 #1
7 2533
There is no connection between the server and the client other than when a
request is made - so javascript would be the most appropriate way. There is
a server side class called the HttpBrowserCapabilities Class but it only
gathers the capabilities of the browser, not the screen the browser as a
client runs within. This would however allow you to check if the client
supports javascript, and thus send some javascript to gather the client
screen dimensions.

You can look at it here.
http://msdn.microsoft.com/library/de...mberstopic.asp
The javascript approach is very easy, theres a good example here:
http://www.devcity.net/Articles/64/1...esolution.aspx

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Bredahl jensen" <br************@yahoo.dk> wrote in message
news:ep**************@TK2MSFTNGP09.phx.gbl...

Most of the the solution i have seen was throught javascript.
Many thanks in advance
JB

Nov 19 '05 #2
Right i know there is no permanent connection between client and web app but
there is at least one a every request..
The Context objects gathers a lot of client side data and i thought there
was some similar object for screen resolution.

Anyway many thanks for you excellents links.

JB
Nov 19 '05 #3
John Timney (ASP.NET MVP) wrote:
There is no connection between the server and the client other than
when a request is made - so javascript would be the most appropriate
way. There is a server side class called the HttpBrowserCapabilities Class but it only gathers the capabilities of
the browser, not the screen the browser as a client runs within. This
would however allow you to check if the client supports javascript,
and thus send some javascript to gather the client screen dimensions.


And those browsercapabilities are based on what is *defined* for a particular
browser-string, NOT what this particular client actually *can* do:

* browser could be capable of javascript, but the user can have switched
that off -- not detected
* some browsers (Opera) allow user-defined browser-strings -- incorrect detection
* the list of capabilities per browser-string is out-of-date -- newer browsers
(Firefox) are not detected correctly (with the original browserCaps)
Hans Kesting
Nov 19 '05 #4
re:
* the list of capabilities per browser-string is out-of-date -- newer browsers
(Firefox) are not detected correctly (with the original browserCaps)
I strongly recommend that *everybody* update
their BrowserCaps section per the code at this link :

http://slingfive.com/pages/code/brow...aps_spaces.txt

Modifying the site's web.config per the code at that page will send HTML
which Firefox, Mozilla, Konqueror, Opera and Mac's Safari can understand.

That makes for a huge difference in accessibility.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:eF**************@TK2MSFTNGP15.phx.gbl... John Timney (ASP.NET MVP) wrote:
There is no connection between the server and the client other than
when a request is made - so javascript would be the most appropriate
way. There is a server side class called the HttpBrowserCapabilities Class but it only
gathers the capabilities of
the browser, not the screen the browser as a client runs within. This
would however allow you to check if the client supports javascript,
and thus send some javascript to gather the client screen dimensions.


And those browsercapabilities are based on what is *defined* for a particular
browser-string, NOT what this particular client actually *can* do:

* browser could be capable of javascript, but the user can have switched
that off -- not detected
* some browsers (Opera) allow user-defined browser-strings -- incorrect detection
* the list of capabilities per browser-string is out-of-date -- newer browsers
(Firefox) are not detected correctly (with the original browserCaps)
Hans Kesting

Nov 19 '05 #5
Not without a client script gathering the information first.

Take a look at the section on HTTP messages on the W3C web site. It will
give you a great understanding of exactly what's being passed between the
client and server.

check out
ftp://ftp.isi.edu/in-notes/rfc2616.txt
Section 4 - HTTP Message
and
Section 5 - Requests
"Bredahl jensen" wrote:

Most of the the solution i have seen was throught javascript.
Many thanks in advance
JB

Nov 19 '05 #6
> Most of the the solution i have seen was throught javascript.

That's the only way.

Also note that screen resolution != browser viewport size.

-Darrel
Nov 19 '05 #7
you are entirely correct Hans

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:eF**************@TK2MSFTNGP15.phx.gbl...
John Timney (ASP.NET MVP) wrote:
There is no connection between the server and the client other than
when a request is made - so javascript would be the most appropriate
way. There is a server side class called the HttpBrowserCapabilities
Class but it only gathers the capabilities of
the browser, not the screen the browser as a client runs within. This
would however allow you to check if the client supports javascript,
and thus send some javascript to gather the client screen dimensions.


And those browsercapabilities are based on what is *defined* for a
particular
browser-string, NOT what this particular client actually *can* do:

* browser could be capable of javascript, but the user can have switched
that off -- not detected
* some browsers (Opera) allow user-defined browser-strings -- incorrect
detection
* the list of capabilities per browser-string is out-of-date -- newer
browsers
(Firefox) are not detected correctly (with the original browserCaps)
Hans Kesting

Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

157
by: Dennis | last post by:
Is there some way --using, say, DOM or javascript-- to detect the current pixel width and/or height of a relatively sized table or of one of its columns or rows. I'm going to be writing javascript...
1
by: simchajoy2000 | last post by:
Is there anyway to dynamically detect the screen resolution of a client's computer in ASP.NET?? All the code I have found on the internet was specifically for Access forms. I found this code: ...
8
by: Brent | last post by:
Does anyone know the best way to detect and track a visitors screen resolution. I know the javascript to detect the users resolution but I am a bit confused on the best way to track and save this....
2
by: chaoy | last post by:
Hi, I created a user control as my site header. The user control consists a custom control, cmenu. I have tried using table to center the cmenu, and no luck. The cmenu just uses top=xxx, and...
2
by: EMW | last post by:
I created my page to work on a 800x600 size window, but when the user has his/her screen set on a larger size, they'll get a empty area at the right side of the screen. I don't like this, looks...
3
by: Luis Esteban Valencia | last post by:
Detect screen resolution? IS THAT POSSIBLE? -- LUIS ESTEBAN VALENCIA MICROSOFT DCE 2. MIEMBRO ACTIVO DE ALIANZADEV
7
by: Chris | last post by:
Can anybody tell me how to detect is the user has closed the browser Thank you
18
by: DavidS | last post by:
Have resW=screen.width; resH=screen.height in javascript. How can I read these values in ASP.NET source code - Page_Load function of code behind? Any suggestions?
8
by: Bjorn Sagbakken | last post by:
Can screen resolution be detected with server code (in Page_Load) ? I have tried this: public int Width = Convert.ToInt32(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width); public...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.