I have a c# code, I need it to be implemeneted only if the client's browser width is smaller than 1200px

I tried this code:

  $(document).ready(function () {
        $("#clientScreenWidth").val($(window).width());
        $("#clientScreenHeight").val($(window).height());
    });
<body>
<input type="hidden" value=""
       name="clientScreenHeight" id="clientScreenHeight" />
<input type="hidden" value=""
       name="clientScreenWidth" id="clientScreenWidth" />
       
       
       
       
  @{
   string height = HttpContext.Current.Request.Params["clientScreenHeight"];
    string width = HttpContext.Current.Request.Params["clientScreenWidth"];
    
  if(width <1200)
  {
      foreach (var component in leftSideComponents)
        {
          //// Code
        }
  }
  
  
  }
  
  </body>

but the width returned null.

Is there any one knows how to implement that ?

Thanks

Related posts

Recent Viewed