detecting client DPI setting in ASP.Net app

Discussion in 'ASP .Net' started by Ray Porter, Sep 24, 2009.

  1. Ray Porter

    Ray Porter Guest

    I've figured out how to detect the client's screen width and height but is
    there anyway to do the same for the client DPI setting?

    I can do this in a Delphi/Intraweb isapi app but I haven't found how to do
    it in C#/ASP.Net.

    Thanks,
    =================================
    Ray Porter
    Information Systems
    Applications Development Manager
    Division of University Advancement
    University of North Carolina at Chapel Hill
    Phone: (919) 259-9389
    Fax: (919) 843-3314
    Pager: (919) 216-4218


    http://www.unc.edu/~dragon

    Meddle not in the affairs of dragons for thou
    art crunchy and taste good with ketchup
    Ray Porter, Sep 24, 2009
    #1
    1. Advertising

  2. Ray Porter

    George Guest

    1. I wonder how you did it with Delphi/Intraweb isapi app

    My guess in order to detect DPI you need some executable to sit on the
    clients computer
    The way it's usually done is using Flash. It's some executable that is
    sitting on clients computer but lucky for us almost everyone has it.


    George.


    "Ray Porter" <> wrote in message
    news:...
    > I've figured out how to detect the client's screen width and height but is
    > there anyway to do the same for the client DPI setting?
    >
    > I can do this in a Delphi/Intraweb isapi app but I haven't found how to do
    > it in C#/ASP.Net.
    >
    > Thanks,
    > =================================
    > Ray Porter
    > Information Systems
    > Applications Development Manager
    > Division of University Advancement
    > University of North Carolina at Chapel Hill
    > Phone: (919) 259-9389
    > Fax: (919) 843-3314
    > Pager: (919) 216-4218
    >
    >
    > http://www.unc.edu/~dragon
    >
    > Meddle not in the affairs of dragons for thou
    > art crunchy and taste good with ketchup
    >
    George, Sep 25, 2009
    #2
    1. Advertising

  3. Ray Porter

    Ray Porter Guest

    Delphi with IntraWeb allows you to program, for the most part, just as you
    would for a desktop app. Intraweb automatically generates any client-side
    Javascript code needed to make it all work.

    I found the solution myself for Visual Studio. I finally, after hours of
    searching, found a site providing fairly complete documentation for the
    Javascript "screen" object that exposes various attributes of the client,
    including width, height and dpi. The solution is simply to write a little
    Javascript snippet in the aspx file to get the necessary values from the
    screen object then stick those values in corresponding hidden inputs on the
    form. Since I couldn't find a complete, intelligible example anywhere (all
    partial snippets), I'll include it here for anyone else who might need it.
    I haven't looked closely at the IntraWeb javascript but I imagine it does
    the samething -- it just does it for you.

    In your C# code, just read Request.Form["ScreenWidth"], etc.

    <script type="text/javascript" language="javascript">
    var width = screen.width;
    var height = screen.height;
    var dpi = screen.deviceXDPI;
    window.onload = function() {
    document.getElementById("ScreenWidth").value = width;
    document.getElementById("ScreenHeight").value = height;
    document.getElementById("ScreenDPI").value = dpi;
    }
    </script>

    <input type="hidden" name="ScreenWidth" />
    <input type="hidden" name="ScreenHeight" />
    <input type="hidden" name="ScreenDPI" />

    Ray


    "George" <> wrote in message
    news:...
    > 1. I wonder how you did it with Delphi/Intraweb isapi app
    >
    > My guess in order to detect DPI you need some executable to sit on the
    > clients computer
    > The way it's usually done is using Flash. It's some executable that is
    > sitting on clients computer but lucky for us almost everyone has it.
    >
    >
    > George.
    >
    >
    > "Ray Porter" <> wrote in message
    > news:...
    >> I've figured out how to detect the client's screen width and height but
    >> is there anyway to do the same for the client DPI setting?
    >>
    >> I can do this in a Delphi/Intraweb isapi app but I haven't found how to
    >> do it in C#/ASP.Net.
    >>
    >> Thanks,
    >> =================================
    >> Ray Porter
    >> Information Systems
    >> Applications Development Manager
    >> Division of University Advancement
    >> University of North Carolina at Chapel Hill
    >> Phone: (919) 259-9389
    >> Fax: (919) 843-3314
    >> Pager: (919) 216-4218
    >>
    >>
    >> http://www.unc.edu/~dragon
    >>
    >> Meddle not in the affairs of dragons for thou
    >> art crunchy and taste good with ketchup
    >>

    >
    Ray Porter, Sep 26, 2009
    #3
    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. Swapnajit Mittra
    Replies:
    0
    Views:
    1,035
    Swapnajit Mittra
    Sep 21, 2004
  2. Swapnajit Mittra
    Replies:
    0
    Views:
    928
    Swapnajit Mittra
    Apr 12, 2005
  3. Swapnajit Mittra
    Replies:
    0
    Views:
    501
    Swapnajit Mittra
    Apr 24, 2005
  4. =?Utf-8?B?Um9iQEhU?=

    Detecting DPI setting on client

    =?Utf-8?B?Um9iQEhU?=, Aug 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    479
    =?Utf-8?B?Um9iQEhU?=
    Aug 9, 2004
  5. =?Utf-8?B?U2VraGFy?=
    Replies:
    3
    Views:
    371
    =?Utf-8?B?U2VraGFy?=
    Jul 10, 2007
Loading...

Share This Page