How can I get the screen width on the server side in an Asp.net (C#) project?
Place this on your form:
<input type="hidden" value=""
name="clientScreenHeight" id="clientScreenHeight" />
<input type="hidden" value=""
name="clientScreenWidth" id="clientScreenWidth" />
This is onload script:
$(document).ready(function () {
$("#clientScreenWidth").val($(window).width());
$("#clientScreenHeight").val($(window).height());
});
This is server side code:
string height = HttpContext.Current.Request.Params["clientScreenHeight"];
string width = HttpContext.Current.Request.Params["clientScreenWidth"];
Use code below
int width = (Request.Browser.ScreenPixelsWidth) * 2 - 100;
int height = (Request.Browser.ScreenPixelsHeight) * 2 - 100;
You could read it with javascript and submit the results to the server.
A server-side-only solution can not exist, since html does not submit such data automatically in requests.
to get the Characters
Request.Browser.ScreenCharactersWidth
Request.Browser.ScreenCharactersHeight
to get the Resolution
you need to send the data from client side with javascript or jquery i use this code its good the work
var ScreenPixelsHeight = window["innerHeight"];
var ScreenPixelsWidth = window["innerWidth"];
var JSLink = "http://www + "&ScreenPixelsHeight="+ScreenPixelsHeight+
"&ScreenPixelsWidth="+ScreenPixelsWidth;