title: asp.net passing values from JS/jquery to code behind c#
body: <p>I have tried "every" possible way of sending the screen.width vlaue from the JS script on the aspx page to the c# in the code behind and while I can see the screen.width being assigned correctly it never gets assigned to my hidden field value. </p>
  
  <pre><code>&lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;
  
     &lt;asp:HiddenField ID="hiddenfield" runat="server" /&gt;
  
     &lt;script type="text/javascript" language="javascript"&gt;
         $(function(){ 
         $('#hiddenfield').val(screen.width); 
      });
      &lt;/script&gt;
  
  other content
  
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>and the code behind:</p>
  
  <pre><code>protected void btnChartGo_Click(object sender, EventArgs e)
  {
     string s = hiddenfield.Value;
  }
  </code></pre>
  
  <p>No matter what I try s is always ""</p>
  
  <p>Something wrong with the above, everyone seems to be doing it like that and it works?</p>