Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET
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 14-Apr-13 21:42pm
maan_k446
Comments
Sergey Alexandrovich Kryukov at 15-Apr-13 2:53am
   
How about thinking just a bit, could you? :-)
—SA
aspnet_regiis -i at 15-Apr-13 3:11am
   
It will be better if you explain why you need it
maan_k at 15-Apr-13 3:25am
   
i want to set the iframe height at runtime means acc. to content window's size
aspnet_regiis -i at 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 at 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 at 15-Apr-13 12:03pm
   
you would do that with javascript, not server side code. You can find a possible solution here:
 
http://stackoverflow.com/questions/819416/adjust-width-height-of-iframe-to-fit-with-content-in-it
Rate this: bad
good
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
  Permalink  
v2
Comments
Dave Kreskowiak at 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 at 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 at 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
good
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.
 
—SA
  Permalink  

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

  Print Answers RSS
0 BillWoodruff 330
1 Mathew Soji 309
2 Maciej Los 295
3 DamithSL 225
4 Afzaal Ahmad Zeeshan 217
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,025


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 15 Apr 2013
Copyright © CodeProject, 1999-2014
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