Total Productivity Solutions, Inc. Company Logo
TPS Home
.NET
IIS
Networking
Search Engine
SharePoint
Add URL

Detecting User Screen Resolution

To detect a user's screen resolution the use of some type of client-side script will be necessary.  Below you will see a javascript example that can be used to detect the screen resolution:
res = “&res=“ + screen.width + “x“ + screen.height + “&d=“ + screen.colorDepth
top.location.href = “detectscreen.aspx?action=set“ + res
The above code needs to be placed within script tags and is written as if it were being run on a page named detectscreen.aspx.  The server side code that can then be used to place the screen resolution values into a session variable would be:
if(Request.QueryString[“action“] != null){
Session[“ScreenResolution“] = Request.QueryString[“res“].ToString();
Response.Redirect(“default.aspx“);
}
The above server-side code would be placed in the Page_Load method of the detectscreen.aspx page.  To use the detectscreen.aspx you could either set your website to call it first or you could redirect to this page from your existing main page.
Home Contact Us Site Map