This turely bugged my head the whole night yesterday! I have javascript that successfully calculates the browser width n height then stores them by updating (client-side) the inner-text of two respective Labels, one stores width, the other stores height.
The problem is that whenever I attempt to use such data by code-behind server-side, they seem getting nulled. Just evaporates!
Googling the matter, I found many ideas like saving data in cookies where server can access them. Some have recommended AJAX, some recommeded saving data in hidden fields then access by the server. The thing is that none has given a realiable working example!
So, can you recommend any direction to move? I will appreciate if example code will be included?
This is HTML & Javascript I'm using to calculate the browser dimensions:
<asp:Label ID="lbl_BrowserWidth" runat="server"></asp:Label>
<asp:Label ID="lbl_BrowserHeight" runat="server"></asp:Label>
<script type="text/javascript">
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var x = document.getElementById("lbl_BrowserWidth");
x.innerText = w;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
var y = document.getElementById("lbl_BrowserHeight");
y.innerText = h;
</script>
Thanks ...