Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. get screen resolution

get screen resolution

Scheduled Pinned Locked Moved ASP.NET
csharpquestionjavascriptasp-net
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kani98
    wrote on last edited by
    #1

    I have a ASP.Net web application using C#, is there a way for me to get the PC screen resolution? I think I have to use javascript for this, but I don't know the syntax. If I have to use javascript, how do I get the value from the javascript variable into a C# variable? Thanks.

    P E 2 Replies Last reply
    0
    • K kani98

      I have a ASP.Net web application using C#, is there a way for me to get the PC screen resolution? I think I have to use javascript for this, but I don't know the syntax. If I have to use javascript, how do I get the value from the javascript variable into a C# variable? Thanks.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Use the Javascript screen[^] object to obtain the screen resolution. In your Javascript code, store the resolution info in hidden fields set to run server-side, then retrieve the info in your server-side code when you post the page back.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      K 1 Reply Last reply
      0
      • P pmarfleet

        Use the Javascript screen[^] object to obtain the screen resolution. In your Javascript code, store the resolution info in hidden fields set to run server-side, then retrieve the info in your server-side code when you post the page back.

        Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        K Offline
        K Offline
        kani98
        wrote on last edited by
        #3

        Can you point me to an example of storing the resolution in hidden fields set to run server-side?

        P 1 Reply Last reply
        0
        • K kani98

          Can you point me to an example of storing the resolution in hidden fields set to run server-side?

          P Offline
          P Offline
          pmarfleet
          wrote on last edited by
          #4

          I don't have an example to hand. However I suggest you look at the HiddenField control.

          Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

          1 Reply Last reply
          0
          • K kani98

            I have a ASP.Net web application using C#, is there a way for me to get the PC screen resolution? I think I have to use javascript for this, but I don't know the syntax. If I have to use javascript, how do I get the value from the javascript variable into a C# variable? Thanks.

            E Offline
            E Offline
            Elayaraja Sambasivam
            wrote on last edited by
            #5

            Hi try to accomodate your page at any resolution, this is the best way to persent your pages, if you have any complicated design, use screen.availHeight, screen.availWidth, best way to keep the resolution in the server side, in the login screen, send this height and width as comma separated values by hidden control. once you authenticated the page, you will keep some user information in the session, same time keep this height and width in your session, Note: if the user resize the screen, server side values can't updated. Regards Elayaraja.S

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups