title: How do I call a method from aspx file?
body: <p>I'm trying to call a method from my aspx file, same class as defined in Page <code>Inherit</code>.</p>
  
  <p>The method is defined like this:</p>
  
  <p>in <strong>foo.aspx.cs</strong></p>
  
  <pre><code>   public void GeneratePartiesOptionsList()
          {
             //parties is a non-empty static readonly array of string[] type
              Debug.WriteLine("GeneratePartiesOptionsList() called");
              foreach(string party in parties)
              {
                  Response.Write(string.Format("&lt;option value='{0}'&gt;{0}&lt;/option&gt;{1}", party, Environment.NewLine));
              }
          }
  </code></pre>
  
  <p>and from foo.aspx, I call like this:</p>
  
  <pre><code>&lt;select id="list" runat="server"&gt;
                              &lt;%
                                  this.GeneratePartiesOptionsList();
                               %&gt;
                          &lt;/select&gt;
  </code></pre>
  
  <p>But when I open <strong>foo.aspx</strong> page I didn't get anything, neither the contents that I wanted to generate nor errors. The select is empty. What am I missing? I'm new to ASP.NET/WebForms.</p>