title: ContentPlaceHolders: Repeated Content
body: <h1>Scenario</h1>
  
  <p>I have an application using asp.net Master Pages in which I would like to repeat some content at the top and bottom of a page.  Currently i use something like this:</p>
  
  Master Page
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;asp:ContentPlaceHolder ID="Foo" runat="server"&gt;
      &lt;/asp:ContentPlaceHolder&gt;
      &lt;!-- page content --&gt;
      &lt;asp:ContentPlaceHolder ID="Bar" runat="server"&gt;
      &lt;/asp:ContentPlaceHolder&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  Content Page
  
  <pre><code>&lt;asp:Content ID="Top" ContentPlaceHolderID="Foo" runat="server"&gt;
    &lt;!-- content --&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Bottom" ContentPlaceHolderID="Bar" runat="server"&gt;
    &lt;!-- content repeated --&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <h1>Maintenance</h1>
  
  <p>As you know, repeating things in code is usually not good.  It creates maintenance problems.  The following is what I would like to do but will obviously not work because of the repeated id attribute:</p>
  
  Master Page
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
      &lt;asp:ContentPlaceHolder ID="Foo" runat="server"&gt;
      &lt;/asp:ContentPlaceHolder&gt;
      &lt;!-- page content --&gt;
      &lt;asp:ContentPlaceHolder ID="Foo" runat="server"&gt;
      &lt;/asp:ContentPlaceHolder&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  Content Page
  
  <pre><code>&lt;asp:Content ID="Top" ContentPlaceHolderID="Foo" runat="server"&gt;
    &lt;!-- content (no repetition) --&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <h1>Possible?</h1>
  
  <p>Is there a way to do this using asp.net webforms?  The solution does not necessarily have to resemble the above content, it just needs to work the same way.</p>
  
  <h1>Notes</h1>
  
  <p>I am using asp.net 3.0 in Visual Studio 2008</p>