Brwoser and screen width?

Discussion in 'ASP .Net' started by John Baima, Jul 4, 2009.

  1. John Baima

    John Baima Guest

    I'd like to know how wide the browser window is at any given time as
    well as the screen width with ASP.NET. Is there an easy way to do
    that? Thanks.

    -John
    John Baima
     
    John Baima, Jul 4, 2009
    #1
    1. Advertising

  2. John Baima

    John Baima Guest

    Re: Browser and screen width?

    "Mark Rae [MVP]" <> wrote:
    >> I'd like to know how wide the browser window is at any given time as
    >> well as the screen width with ASP.NET. Is there an easy way to do
    >> that?

    >
    >This is a property of the browser which isn't passed to the server as part
    >of the request's server variables collection. This means that it's not
    >available server-side directly.
    >
    >However, you can retrieve this via client-side JavaScript. This is a bit of
    >an inexact science, as different browsers use different properties for this
    >information, e.g.
    >
    >screen.width
    >screen.availWidth
    >window.innerWidth
    >document.documentElement.clientWidth
    >document.body.clientWidth
    >
    >If you need these values server-side, your only option is to populate hidden
    >fields with their values so that they can be inspected during postbacks...


    Do you have any examples of this? I do mostly winform programming but
    I would have thought that this would be something that lots of people
    would be interested in.

    -John

    John Baima
     
    John Baima, Jul 5, 2009
    #2
    1. Advertising

  3. Re: Browser and screen width?

    re:
    !> Do you have any examples of this?

    http://www.google.com/search?hl=en&q=screen.width

    re:
    !> I would have thought that this would be something that lots of people would be interested in.

    They are...




    Juan T. Llibre, asp.net MVP
    ¿ Estas probando VS 2010 y ASP.NET 4.0 ?
    Regístrate (gratis) en los Foros de VS 2010 y ASP.NET 4.0, en español
    http://asp.net.do/foros/forums/
    =====================================================
    "John Baima" <> wrote in message news:...
    > "Mark Rae [MVP]" <> wrote:
    >>> I'd like to know how wide the browser window is at any given time as
    >>> well as the screen width with ASP.NET. Is there an easy way to do
    >>> that?

    >>
    >>This is a property of the browser which isn't passed to the server as part
    >>of the request's server variables collection. This means that it's not
    >>available server-side directly.
    >>
    >>However, you can retrieve this via client-side JavaScript. This is a bit of
    >>an inexact science, as different browsers use different properties for this
    >>information, e.g.
    >>
    >>screen.width
    >>screen.availWidth
    >>window.innerWidth
    >>document.documentElement.clientWidth
    >>document.body.clientWidth
    >>
    >>If you need these values server-side, your only option is to populate hidden
    >>fields with their values so that they can be inspected during postbacks...

    >
    > Do you have any examples of this? I do mostly winform programming but
    > I would have thought that this would be something that lots of people
    > would be interested in.
    >
    > -John
    >
    > John Baima
     
    Juan T. Llibre, Jul 5, 2009
    #3
  4. John Baima

    John Baima Guest

    Re: Browser and screen width?

    "Mark Rae [MVP]" <> wrote:
    >Depends what you intend to do with the information, and whether you need to
    >know it client-side or server-side...
    >
    >Can you provide a bit more information about what you're trying to do...?


    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. So,
    I have to know how wide each of the elements are and how much screen
    I have to work with.

    I did get the scheme of:

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

    working and extended it to what I need. Now I just need to know the
    width of text elements :)

    -John

    John Baima
     
    John Baima, Jul 5, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    841
    Bruce Barker
    Oct 10, 2005
  2. kris
    Replies:
    11
    Views:
    900
  3. Lois
    Replies:
    1
    Views:
    3,409
    Ryan Stewart
    Dec 27, 2004
  4. Biranchi Narayan Panda
    Replies:
    1
    Views:
    2,840
    Alexey Smirnov
    Feb 17, 2010
  5. JJA
    Replies:
    2
    Views:
    169
    Dr J R Stockton
    Oct 28, 2006
Loading...

Share This Page