|
|
|
date: Sat, 04 Jul 2009 17:43:53 -0500,
group: microsoft.public.dotnet.framework.aspnet
back
Re: Browser and screen width?
"John Baima" wrote in message
news:7p2155175edhbjoq80uhdcral0snjp87q0@4ax.com...
> I did get the scheme of:
>
> http://www.devcity.net/Articles/64/1/screenresolution.aspx
>
> working and extended it to what I need.
Ignore that page completely. It is *seriously* out-of-date, e.g. <script
language="javascript"> - the language tag of the <script /> element has been
deprecated for nearly THIRTEEN years!!!
Did you read all of the comments at the bottom of the article? Specifically,
what happens if the user changes their screen resolution?
Apart from that, obviously detecting the client machine's screen resolution
(e.g. 1280*1024) does not tell you how the width of the client browser
unless it is maximised - that's why you need to know the current width of
the browser, not the width of the screen...
> I need it server side. I have several text items in a database that I
> want to display and I want to get as many columns as possible in a
> table, but I don't want the user to have to scroll right and left.
But that's the way web browsers work! Users will be well used to this sort
of behaviour...
> So, I have to know how wide each of the elements are and how much screen
> I have to work with.
Not possible server-side. The reason is that, unless you explicitly set the
width of DOM elements, the web browser will do this automatically as its
parsing the HTML stream response being received from the webserver. And, by
that time, it's too late for the server to do anything to the HTML stream...
Your best bet would be to set the widths of the controls explicitly and let
the contents wrap...
I really do think you're making things unnecessarily difficult for
yourself...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
date: Sun, 5 Jul 2009 12:40:36 +0100
author: Mark Rae [MVP]
|
|