Call c# function in javascript
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3713/call-asp-net-function-from-javascript">Call ASP.NET Function From Javascript?</a>  </p>
</blockquote>



<p>I have a C# function containing an if statement </p>

<pre><code>if (condition) 
    test=true 
else 
    test= false 
</code></pre>

<p>How do I call that function in javascript and use the result of that test variable to do an if statement ?</p>

<p>The c# file I am referencing is the code behind (.aspx.cs) to an .aspx page. Is there not a way I can call the following function from this .aspx page.</p>

<pre><code>public void write(bool complete)
{
    System.IO.StreamWriter writer = new System.IO.StreamWriter(Server.MapPath("~file.txt"), true);

    if (complete == true)
    {
        writer.WriteLine("completed");
    }
    else
    {
        writer.WriteLine("FAILED");
    }
    writer.Flush();
    writer.Close();
    writer.Dispose();
}
</code></pre>
