I am trying to retrieve width of my browser in pixels but for some reason I am getting back 640, my resolution is at 1240.
Code I am using is Request.Browser.ScreenPixelsWidth
Does anyone knows why it returns 640 always or if there is another way for me to get the width of the browser upon page load?
You need to populate a hidden field with Javascript (see this question for how to do that), and then send that field back to the server so that it's avaialble within ASP.NET.
ASP.NET is incapable of reading detailed browser information like that directly (you're talking about sending some very specific information from the client's browser to the ASP.NET server where your application is hosted, and there are a lot of problems involved with doing something like that).
See this similar, but less detailed, question:
Asp.Net Get Screen Width
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With