asp.net get window width/height in server side

mybwu_com發表於2013-12-30


Step 1:


put a hidden field on asp.net page

<asp:HiddenField ID="width" runat="server" />
<asp:HiddenField ID="height" runat="server" />


Step 2: use jquery set value


<script type="text/javascript">


$(document).ready(function() {


    $("#width").val() = $(window).width();
    $("#height").val() = $(window).height();    


});


</script>


Step 3: use in asp.net code behind

相關文章