ASP.NET C#获取像素屏幕宽度 [英] ASP.NET c# get screen width in pixels

查看:1716
本文介绍了ASP.NET C#获取像素屏幕宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找回我的浏览器的宽度以像素为单位,但由于某种原因,我又回到640,我的分辨率是1240。

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我现在用的就是 Request.Browser.ScreenPixelsWidth

Code I am using is Request.Browser.ScreenPixelsWidth

有谁知道为什么它会返回640总是或有另一种方式对我来说,在网页加载时获取浏览器的宽度是多少?

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?

推荐答案

您需要填充一个隐藏字段使用Javascript(见<一href=\"http://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-$c$c\">this问题如何做到这一点),然后该字段发送回服务器,以便它在ASP.NET的avaialble。

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是无法读取详细的浏览器信息一样,直接(你在谈论从发送客户端浏览器的一些非常具体的信息到你的应用程序托管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获取屏幕宽度

这篇关于ASP.NET C#获取像素屏幕宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆