|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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 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/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpbrowsercapabilitiesmemberstopic.asp The javascript approach is very easy, theres a good example here: http://www.devcity.net/Articles/64/1/screenresolution.aspx -- Show quoteHide quoteRegards John Timney ASP.NET MVP Microsoft Regional Director "Bredahl jensen" <bredhal.jen***@yahoo.dk> wrote in message news:ep7vhMabFHA.2696@TK2MSFTNGP09.phx.gbl... > > Most of the the solution i have seen was throught javascript. > > > Many thanks in advance > > > JB > > 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 John Timney (ASP.NET MVP) wrote:
> There is no connection between the server and the client other than And those browsercapabilities are based on what is *defined* for a particular> 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. > 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 re:
> * the list of capabilities per browser-string is out-of-date -- newer browsers I strongly recommend that *everybody* update> (Firefox) are not detected correctly (with the original browserCaps) their BrowserCaps section per the code at this link : http://slingfive.com/pages/code/browserCaps/browserCaps_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... ====================== Show quoteHide quote "Hans Kesting" <news.2.hansdk@spamgourmet.com> wrote in message news:eFv2FCbbFHA.1504@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 > > you are entirely correct Hans
-- Show quoteHide quoteRegards John Timney ASP.NET MVP Microsoft Regional Director "Hans Kesting" <news.2.hansdk@spamgourmet.com> wrote in message news:eFv2FCbbFHA.1504@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 > > 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 Show quoteHide quote "Bredahl jensen" wrote: > > Most of the the solution i have seen was throught javascript. > > > Many thanks in advance > > > JB > > >
Other interesting topics
ASP.NET stopped working
ASP.NET tells me my table doesn't have a primary key Viewstate String InvalidCastException how to determine .NET framework version Munging URLs to store data Does CompareValidator work for the date in dd-mmm-yyyy format? Microsoft Bug Transparent images OnPreRender ??? What is ? somebody help me answer this? |
|||||||||||||||||||||||