title: AJAX vs. Server-Side Execution with C# ASP.NET
body: <p>In my previous web development experience I have used LAMP setups.  I am trying to learn the Microsoft way as I develop a project using the following tools:</p>
  
  <ul>
  <li>ASP.NET 3.5</li>
  <li>C#</li>
  <li>MS Visual Studio 2008</li>
  </ul>
  
  <p>Here is my question:  How can I tell when code gets executed on the server versus code that is exectued as javascript?</p>
  
  <p>I have added AJAX functionality to my aspx file using tutorials I found online.  I have something like:</p>
  
  <p>ASP:</p>
  
  <pre><code>&lt;asp:ScriptManager /&gt;
  &lt;asp:UpdatePanel&gt;
      &lt;ContentTemplate&gt;
          &lt;input id="inputItem" type="text" runat="server" /&gt;
          &lt;asp:Button id="submitButton" runat="server"
                      OnClick="submitButton_clicked"/&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>C#:</p>
  
  <pre><code>protected void submitButton_clicked (object sender, EventArgs e)
  {
      // Do dynamic stuff on page.
  }
  </code></pre>
  
  <p>I have been able to successfully update elements on the page without requiring a refresh.  It is my understanding that the C# function submitButton_clicked() is automatically converted to javascript by Visual Studio when the web application is built (as well as any functions called by it).</p>
  
  <p>I need to be able to submit the user-supplied data in this form to the server so that I can add it to a database.  What I do not understand is how to differentiate between code that is automatically converted to javascript and code that is not.  I want to be able to call functions from submitButton_clicked() which use LINQ to perform database operations, and have that code executed server-side.</p>
  
  <p>I have been trying to find some online tutorials which explain this distinction cleary but have had no luck so far.  Any help is appreciated.</p>