title: How can I define a property on an ASP.NET user or server control to allow multiple string values as nested tags with a custom tag name?
body: <p>I need to write a user control that can be used with the following syntax:</p>
  
  <pre><code>&lt;quiz:Question runat="server"&gt;
    &lt;Answer&gt;Foo&lt;/Answer&gt;
    &lt;Answer&gt;Bar&lt;/Answer&gt;
  &lt;/quiz:Question&gt;
  </code></pre>
  
  <p>I tried the following property declaration:</p>
  
  <pre><code>[ParseChildren(true, "Answer")]
  public class Question : UserControl
  {
    [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
    public string[] Answer { get; set; }
  }
  </code></pre>
  
  <p>But then the Visual Studio editor insist that <code>&lt;Answers &gt;</code> should be self-closing and I get this exception if I decide otherwise:</p>
  
  <blockquote>
    <p>Literal content ('Foo') is not allowed within a 'System.String[]'.</p>
  </blockquote>
  
  <p>I have been looking at <code>&lt;asp:DropDownList&gt;</code> in Reflector, which inherits from <code>ListControl</code> which declares the <code>Items</code> property as follows:</p>
  
  <pre><code>ParseChildren(true, "Items")
  public abstract class ListControl
  {
    [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
    public virtual ListItemCollection Items { get; }
  }
  </code></pre>
  
  <p>It's not really the same as what I want, because in <code>DropDownList</code> you must add <code>&lt;asp:ListItem&gt;</code> as children. And there are some things I don't understand about control design, which is currently preventing me from finding the solution:</p>
  
  <ul>
  <li>Why doesn't the <code>&lt;asp:ListItem&gt;</code> tag require a <code>runat="server"</code> attribute?</li>
  <li>Can I declare such a 'control'?</li>
  <li>What's so special about the ListItemCollection that it translates to this particular syntax?</li>
  <li>What code can I write that will translate to the syntax given in the first code example above?</li>
  </ul>