Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
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
Posted
Comments
Sergey Alexandrovich Kryukov 15-Apr-13 2:53am    
How about thinking just a bit, could you? :-)
—SA
bbirajdar 15-Apr-13 3:11am    
It will be better if you explain why you need it
maan_k 15-Apr-13 3:25am    
i want to set the iframe height at runtime means acc. to content window's size
bbirajdar 15-Apr-13 3:28am    
Then set it as a percentage in the iframe style tag.. You dont need to know the actual height of window then
maan_k 15-Apr-13 3:35am    
what my need is,if i open larger page then it should be adjust in iframe and if i open shorter page,then automatically iframe height should be resized according to page

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
 
Share this answer
 
v2
Comments
Dave Kreskowiak 15-Apr-13 12:25pm    
So what would you do in the event the browser window is being resized constantly?

The bottom line is that the question doesn't make any real sense as serv-erside code should not be called during a resize event in a client browser. Imagine your server being pummeled by 5,000 clients all resizing their windows at the same time. It's just not practical for the server-side code to give a rats ass what shape the browser window is.
pdoxtader 15-Apr-13 12:39pm    
I completely agree. I didn't say that you SHOULD do it, just that you can. And just because I can't imagine why you would want to do such a thing, that doesn't mean that someone else doesn't have an awesome idea, and is in the process of amazing us all.

Besides that, I did add above that you wouldn't do that with server side code, that you would instead do it with javascript. I even posted a link to an example.

This guy just needs to lean about all this, and come to understand what to use for what, and when. So why not give him some real information?
Dave Kreskowiak 15-Apr-13 14:37pm    
that doesn't mean that someone else doesn't have an awesome idea

HAHAHAHAHA!!! In a forum question?? VERY rarely does that ever happen. Now, if he put up a blog post with the solution...
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900