Asp.Net Get Screen Width

后端 未结 4 1597
囚心锁ツ
囚心锁ツ 2021-01-03 11:00

How can I get the screen width on the server side in an Asp.net (C#) project?

4条回答
  •  粉色の甜心
    2021-01-03 11:24

    Place this on your form:

    
    
    

    This is onload script:

    $(document).ready(function () {
        $("#clientScreenWidth").val($(window).width());
        $("#clientScreenHeight").val($(window).height());
    });
    

    This is server side code:

    string height = HttpContext.Current.Request.Params["clientScreenHeight"];
    string width = HttpContext.Current.Request.Params["clientScreenWidth"];
    

提交回复
热议问题