title: Passing html markup into an ASP.NET User Control
body: <p>In the following example,</p>
  
  <pre><code>&lt;uc1:MyUserControl&gt;
  
     &lt;p&gt;this is html&lt;/p&gt;
  
  &lt;/uc1:MyUserControl&gt;
  </code></pre>
  
  <p>How do I access <code>"&lt;p&gt;this is html&lt;/p&gt;"</code> as a string within MyUserControl so that I might inject it into the response? </p>
  
  <p>I'm not talking about passing in a string parameter like <code>&lt;uc1:MyUserControl myparameter="&lt;p&gt;this is html&lt;/p&gt;" /&gt;</code>, but how do I access true multi-lined intellisensed HTML markup either between the opening and closing tags or by some other mechanism such as a <code>&lt;MessageTemplate&gt;</code> tag.</p>
  
  <p>Bonus points for a solution that works in ASP.NET MVC 3!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Thanks to StriplingWarrior and <a href="https://stackoverflow.com/questions/1827648/literal-content-is-not-allowed-within-a-usercontrol/2302755#2302755">this link</a> as the missing puzzle piece, magic was made:</p>
  
  <p>So, in any view:</p>
  
  <pre><code>&lt;%@ Register src="../../Shared/Ribbon.ascx" tagname="Ribbon" tagprefix="uc1" %&gt;
  ...
  &lt;uc1:Ribbon ID="Ribbon" runat="server"&gt;
      &lt;Content&gt;
      Hello world! I am &lt;b&gt;pure html&lt;/b&gt; being passed into a UserControl!
      &lt;/Content&gt;
  &lt;/uc1:Ribbon&gt;
  </code></pre>
  
  <p>In Ribbon.ascx:</p>
  
  <pre><code>&lt;%@ Control Language="C#" CodeBehind="Ribbon.ascx.cs" Inherits="NunYourBeezwax.Views.Shared.Ribbon" %&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;I am reusable stuff that wraps around dynamic content&lt;/td&gt;
          &lt;td&gt;&lt;%= this.Content %&gt;&lt;/td&gt;
          &lt;td&gt;And I am stuff too&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And finally, in Ribbon.ascx.cs (Need to manually add in MVC)</p>
  
  <pre><code>using System.Web.Mvc;
  using System.Web.UI;
  
  namespace NunYourBeezwax.Views.Shared
  {
      [ParseChildren(true, "Content")]
      public class Ribbon : ViewUserControl
      {
          [PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty)]
          public string Content { get; set; }
      }
  }
  </code></pre>
  
  <p>Will Render as:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;I am reusable stuff that wraps around dynamic content&lt;/td&gt;
          &lt;td&gt;Hello world! I am &lt;p&gt;pure html&lt;p&gt; being passed into a UserControl!&lt;/td&gt;
          &lt;td&gt;And I am stuff too&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>