Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9108899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:54:49+00:00 2026-06-17T02:54:49+00:00

I want to access user screen resolution from server side. For this I have

  • 0

I want to access user screen resolution from server side.
For this I have asp hidden control:

<asp:HiddenField runat="server" ID="hdnScreenResolution" />

Which actually rendering on page:

<input type="hidden" name="ctl00$MainContent$hdnScreenResolution" id="MainContent_hdnScreenResolution" />

I use javascript function to insert value in it:

$(document).ready(function () {
   var width = screen.width;
   var height = screen.height;

   var hiddenScreenResolution = document.getElementById('<%= hdnScreenResolution.ClientID
    %>'); 
   hiddenScreenResolution.value = "asass";
});

And it is on page source code:

       $(document).ready(function () {
            var width = screen.width;
            var height = screen.height;

            var hiddenScreenResolution = document.getElementById('MainContent_hdnScreenResolution'); 
            hiddenScreenResolution.value = "asass";
        });

On server side I check hidden value on Page_Load():

protected void Page_Load(object sender, EventArgs e)
{
    var hiddenValue = hdnScreenResolution.Value;
}

But value appears to be empty string.
Using jquery does not help.

Inserting directly:
document.getElementById(‘<%= hdnScreenResolution.ClientID
%>’).value = “asdasd”;
does not help.

What the problem can be?

P.S. I suppose that I catching screen resolution on document.ready is too late.
And javascript fires after page was unloaded. So no change to catch it on initial request.

Looking forward for an answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:54:50+00:00Added an answer on June 17, 2026 at 2:54 am

    The server side Page_Load is called before the html is sent to client and execution of jQuery document.ready so you are accessing value before assigning on client using javascript and you should get empty.

    You need to send values from client to server, you can use jQuery ajax for do postback for getting screen coordinates values on server.

    To see what is happening just add asp:button and access hidden field values in its server side event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get user screen resolution on server side and resize controls according
I want the user to have easy access to Emoji icons in a small
I have a login screen, and I want to pass the login ID from
Currently since I want to access user information in all my templates, I always
I want to access the user data as global in whole website. I make
I want to give a user access to a stored procedure, but not to
I want to access an image stored in Blackberry, say at location store/home/user/image.png .
I want to give permission to a user to access my database using work
I want that when a non logged in user tries to access any controller
I want to post a message on the user's facebook wall using access token.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.