I am using ASP.NET and C#.I can able to get the document height using javascript with this.
var h = document.documentElement.offsetHeight;
Now i need this value during pageload. But the javascript will be start exicuting after pageload. So now i need to get it using server side code(C#).
Is it possible?
EDIT:
In pageload i am planning to set the height for all the tags based on the document height.
So that the page will fit for all resolution.
You can’t get this value using server-side code, as it is, by definition, server-side.
You could however use JavaScript to pass the value back to an ASP.NET script via AJAX, and take whatever action you need to take at this point. Of course this means that you wouldn’t be able to, for example, provide different content onload for different screen sizes, but it all depends on your intentions.
Since you need it on pageload, one very very hacky way to do this would be to detect the browser height and then redirect, for example pass it as a querystring value that you can use directly within PageLoad. What I mean specifically is, use JavaScript to detect this QS value (for example
?ph=768), and if it’s not there, redirect the page to itself, appending on?ph=768. That way you can use it to get the page height on document load.As mentioned by @J.Steen in comments, though, it’s probably better to define your intentions.