title: Passing Javascript value to C# Code Behind
body: <p>I've coded myself into a bit of a corner, and the suggestions I've come across don't seem to be helping.</p>
  
  <p>In summary: I have a modal that takes in a serialized variable from the page on load event, passed through a javascript function that builds from a template of div's on the aspx page. The trouble is there's an ASP:LinkButton in the template that calls an onclick event in C#. I need to be able to pass some of the information that I have access to in the modal to the onclick function in C#.</p>
  
  <p>I've tried using hidden variables but I can't seem to get them to change in the Javascript on the onclick.</p>
  
  <p>Here's the link and hidden field, all in a contenttemplate (I have two, asp and html, been trying both):</p>
  
  <pre><code>&lt;asp:LinkButton ID="lnkbtnProceedChangeStatus" runat="server" OnClick="ProceedChangeStatus_Click" CommandArgument=""&gt;Yes, proceed&lt;/asp:LinkButton&gt;
  &lt;asp:Hiddenfield ID="hiddenInputField" value="test2" runat="server"/&gt;
  &lt;input type="hidden" name="hiddenInputFieldHTML" id="CurrentlySelectedBatchID" value="test1" runat="server"/&gt;
  </code></pre>
  
  <p>I try to use this to change the hidden variable,</p>
  
  <pre><code>document.getElementById('&lt;%= hiddenInputField.ClientID %&gt;').value = "test123";
  </code></pre>
  
  <p>then</p>
  
  <pre><code>string s = hiddenInputField.Value;
  string t = hiddenInputFieldHTML.Value;
  </code></pre>
  
  <p>to try and pull it out in the codebehind, but they never change from their default values.</p>