如何在代码中获取页面的高度 [英] how to get the height of the page in code behind

查看:70
本文介绍了如何在代码中获取页面的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在代码后面获取页面的高度。

i想要访问页面的高度

是否有一些属性如

page.height

解决方案

是的,实际上,你可以。您可以使用javascript获取浏览器窗口的大小,例如这个,并相应地编码。



您可以在这里找到许多可能的解决方案在这个堆栈溢出文章中



虽然似乎没有直接的方法来实现代码隐藏,但您总是可以使用AJAX将其发送到服务器 - 如果您确实需要在服务器端代码中提供该信息(我不知道您为什么会这样做)。可以在这里找到一个简单的AJAX教程。



@Surgey :是的,你是一个很棒的程序员。你清楚地了解我们其他人。因此,当像你这样的人给出这样的答案时,显然只是没有足够的关心给出真正的答案,我发现这非常令人沮丧。为什么不给这个家伙一点真实的信息,就像我刚才那样,所以他可以学习?



- Pete


你无法得到它。没门。整个想法都是错的;如果你试着稍微考虑一下,你会很容易理解它。



页面的高度由许多与服务器无关的因素定义处理。而且,即使在呈现页面时也不知道。原因如下:首先,高度取决于浏览器窗口的宽度,可以由用户随时更改。



-SA

how to get the height of the page in code behind.
i want to access the height of the page
is there some property like
page.height

解决方案

Yes, actually, you can. You can get the size of the browser window using javascript like this, and code accordingly.

You can find a number of possible solutions here In this stack overflow article.

And while there seems to be no direct way to get this to codebehind, you can always send it to the server using AJAX - if you really need to have that information in your server side code (I have no idea why you would). A simple AJAX tutorial can be found here.

@Surgey: Yes, you''re an awesome coder. You clearly know more then the rest of us. So when people like you give answers like this, obviously just not caring enough to give a real answer, I find it to be very frustrating. Why not just give the guy a little real information, like I just did, so he can learn?

- Pete


You cannot get it. No way. The whole idea is wrong; and you would easily understand it if you tried to think at it just a bit.

The height of the page is defined by a number of factors totally irrelevant to the server-side processing. Moreover, it is not known even when the page is rendered. Here is why: first of all, the height depends on the width of the browser window, which can be changed anytime by the user.

—SA


这篇关于如何在代码中获取页面的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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