Understanding hidden fields
<p>I was wondering if you guys could help me understand hidden fields, since I don't think I am getting them to work.</p>

<p>On the aspx page I have:</p>

<pre><code>&lt;asp:HiddenField ID="hidVal" value="" runat="server" /&gt;
</code></pre>

<p>On a button click I have a JavaScript function called</p>

<pre><code>&lt;button type="button" id="search" onclientclick="search_click()"&gt;Search&lt;/button&gt; 
</code></pre>

<p>With the function being</p>

<pre><code>function search_click() {
    document.getElementById('hidVal').Value = "1";

    &lt;% save(); %&gt;
}
</code></pre>

<p>In aspx.cs I have a function that does this: </p>

<pre><code>using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\fgreene\Desktop\savedAdresses.txt", true))
{
    file.WriteLine(hidVal.Value);
}
</code></pre>

<p>After clicking the button I look into the file and there is no change.<br>
Is my approach correct or am I not understanding how this works?</p>
