屏幕分辨率 [英] screen resolution

查看:106
本文介绍了屏幕分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有resW = screen.width; resH = javascript中的screen.height。如何在ASP.NET源代码中读取这些值 - Page_Load代码函数?


有什么建议吗?

Have resW=screen.width; resH=screen.height in javascript. How can I read
these values in ASP.NET source code - Page_Load function of code behind?

Any suggestions?

推荐答案

您需要将值从客户端传递到服务器端。使用隐藏输入控件的标准方法是




< input type = hidden runat = server id = inhResW>

>
Eliyahu


" DavidS" <沓**** @ discussions.microsoft.com>在留言中写道

新闻:BC ********************************** @ microsof t.com ...
You need to pass the values from client to server side. The standard way is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
resW = screen.width; resH = javascript中的screen.height。我怎样才能在ASP.NET源代码中读取这些值 - Page_Load代码后面的函数?

有什么建议吗?
Have resW=screen.width; resH=screen.height in javascript. How can I read
these values in ASP.NET source code - Page_Load function of code behind?

Any suggestions?



我在HTML代码中有以下内容...

< script language =" javascript">

document.getElementById(''resW '')= window.screen.width;

document.getElementById(''resH'')= window.screen.height;

< / script>

< input type = hidden name = resW id = resW runat = server>

< input type = hidden name = resH id = resH runat = server>


如何访问后面的ASP.NET(VB)代码中的值?当我使用Request.Form(resW)或resW.Value时,我一直得到

null值?


我错过了什么?


" Eliyahu Goldin"写道:
I''ve have the following in HTML code...
<script language="javascript">
document.getElementById(''resW'') = window.screen.width;
document.getElementById(''resH'') = window.screen.height;
</script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("resW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:
您需要将值从客户端传递到服务器端。标准方法是使用隐藏的输入控件:

< input type = hidden runat = server id = inhResW>

Eliyahu

DavidS <沓**** @ discussions.microsoft.com>在消息中写道
新闻:BC ********************************** @ microsof t.com。 ..
You need to pass the values from client to server side. The standard way is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
有resW = screen.width; resH = javascript中的screen.height。我怎样才能在ASP.NET源代码中读取这些值 - Page_Load代码函数背后?

有什么建议吗?
Have resW=screen.width; resH=screen.height in javascript. How can I read
these values in ASP.NET source code - Page_Load function of code behind?

Any suggestions?




David,


我可以想到可能发生的两件事。


第一个在发生

回发之前,这两个领域都没有任何价值。第一次你的代码运行页面上没有显示在客户端上的
并且javascript没有填充这些字段。


第二个(如果问题不是第一个)是将控件设置为

runat =" Server"可能会干扰这个过程。如果你打算使用

Request.Form来获取值,那么控件就不必是.Net控件。

你只能使用runat = "服务器"如果你想引用隐藏的输入

作为.Net服务器端控件。要做到这一点,你应该在你的

页面上声明它们:


受保护的事件resW As System.Web.HtmlControls.HtmlGenericControl


(我从内存中键入了这个,所以请仔细检查系统声明......)


但从外观上看,我只是删除了runat ="服务器"然后

仅在回发时执行Request.Form。


-

此致,

S. Justin Gengo,MCP

网站开发人员/程序员

www.aboutfortunate.com


混乱无序。

Nietzsche
" DavidS" <沓**** @ discussions.microsoft.com>在消息中写道

news:9C ********************************** @ microsof t.com ...
David,

I can think of two things that may be happening.

The first is that there won''t be any value in either of those fields until a
postback has occurred. The first time your code runs the page hasn''t
displayed on the client and the javascript hasn''t filled those fields.

The second (if the problem isn''t the first) is that setting the controls as
runat="Server" may be interfering with the process. If you''re going to use
Request.Form to get the values the controls don''t have to be .Net controls.
You would only use runat="Server" if you want to reference the hidden inputs
as .Net server side controls. To do that you should declare them on your
page something like:

Protected WithEvents resW As System.Web.HtmlControls.HtmlGenericControl

(I typed that from memory, so double check the system declaration...)

But from the looks of things I would just remove the runat="Server" and then
do the Request.Form on postback only.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"DavidS" <Da****@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
我在HTML代码中有以下内容...
< script language =" javascript">
document.getElementById( ''resW'')= window.screen.width;
document.getElementById(''resH'')= window.screen.height;
< / script>
<输入type = hidden name = resW id = resW runat = server>
< input type = hidden name = resH id = resH runat = server>

如何访问ASP中的值。 NET(VB)代码背后?当我使用Request.Form(resW)或resW.Value时,我一直得到
空值?

我错过了什么?

Eliyahu高银"写道:
I''ve have the following in HTML code...
<script language="javascript">
document.getElementById(''resW'') = window.screen.width;
document.getElementById(''resH'') = window.screen.height;
</script>
<input type=hidden name=resW id=resW runat=server>
<input type=hidden name=resH id=resH runat=server>

How can I access the values in ASP.NET (VB) code behind? I keep getting
null values when I use Request.Form("resW") or resW.Value?

What am I missing?

"Eliyahu Goldin" wrote:
您需要将值从客户端传递到服务器端。标准方式
使用隐藏的输入控件:

< input type = hidden runat = server id = inhResW>

Eliyahu

DavidS <沓**** @ discussions.microsoft.com>在消息中写道
新闻:BC ********************************** @ microsof t.com。 ..
You need to pass the values from client to server side. The standard way
is
to use hidden input controls:

<input type=hidden runat=server id=inhResW>

Eliyahu

"DavidS" <Da****@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
>有resW = screen.width; resH = javascript中的screen.height。我怎么能
>阅读
> ASP.NET源代码中的这些值 - Page_Load代码函数
>落后?
>
>有什么建议吗?
> Have resW=screen.width; resH=screen.height in javascript. How can I
> read
> these values in ASP.NET source code - Page_Load function of code
> behind?
>
> Any suggestions?




这篇关于屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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