Click here to Skip to main content
12,998,423 members (88,294 online)
Rate this:
Please Sign up or sign in to vote.
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
Posted 14-Apr-13 20:42pm
How about thinking just a bit, could you? :-)
aspnet_regiis -i 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
aspnet_regiis -i 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
pdoxtader 15-Apr-13 12:03pm
you would do that with javascript, not server side code. You can find a possible solution here:
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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
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...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 15 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100