title: VS 2008, ASP.NET: Generate Local Resources
body: <p>I've build an simple control called Menu:</p>
  
  <pre><code>namespace MyControls
  {
      public class MenuItem
      {
          public MenuItem()
          {
              Visible = true;
          }
  
          [Localizable(true)]
          public string Text { get; set; }
          [Localizable(false)]
          public string Link { get; set; }
          [DefaultValue(true)]
          public bool Visible { get; set; }
      }
  
      public class MenuDesigner : System.Web.UI.Design.ControlDesigner
      {
          ...
      }
  
      [ParseChildren(true, "Items")]
      [PersistChildren(false)]
      [Designer(typeof(MenuDesigner))]
      public class Menu : Control
      {
          ...
  
          public Menu()
          {
          }
  
          ...
  
          private List&lt;MenuItem&gt; _items = new List&lt;MenuItem&gt;();
          [PersistenceMode(PersistenceMode.InnerProperty)]
          [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
          public List&lt;MenuItem&gt; Items
          {
              get
              {
                  return _items;
              }
          }
  
          protected override void OnPreRender(EventArgs e)
          {
              base.OnPreRender(e); 
  
              ... // More Controls.
  
              list = new BulletedList();
              list.DisplayMode = BulletedListDisplayMode.HyperLink;
              this.Controls.Add(list);
  
              foreach (var mi in _items)
              {
                  list.Items.Add(new ListItem(mi.Text, Page.Request.CreateUrl(mi.Link)));
              }
          }
      }
  }
  </code></pre>
  
  <p>I use it in my Page this way:</p>
  
  <pre><code>    &lt;my:Menu ID="menu" runat="server" Text="MenuTitle"&gt;
          &lt;my:MenuItem Text="text" Link="link1.aspx"&gt;
          &lt;/my:MenuItem&gt;
          &lt;my:MenuItem Text="text2" Link="link2.aspx"&gt;
          &lt;/my:MenuItem&gt;
      &lt;/my:Menu&gt;
  </code></pre>
  
  <p>This works. No Problems. When I switch to the Designer View I see the Control in the way my MenuDesigner renders it. Reformating with CTRL-K, CTRL-D works. Running my WebPage renders to Menu the way I expected it. </p>
  
  <p>But: when I hit in the DesingView the Menu Item "Tools" -> "Generate Local Resource" I get this result:</p>
  
  <pre><code>&lt;my:Menu ID="menu" runat="server" Text="MenuTitle" 
              meta:resourcekey="menuResource9"&gt;
              &lt;my:MenuItem Text="text" Link="link1.aspx"&gt;
              &lt;/my:MenuItem&gt;
              &lt;my:MenuItem Text="text2" Link="link2.aspx"&gt;
              &lt;/my:MenuItem&gt;
              &lt;Items&gt;
  &lt;my:MenuItem Text="text" Link="link1.aspx" meta:resourcekey="MenuItemResource10"&gt;&lt;/my:MenuItem&gt;
  &lt;my:MenuItem Text="text2" Link="link2.aspx" meta:resourcekey="MenuItemResource11"&gt;&lt;/my:MenuItem&gt;
  &lt;/Items&gt;
          &lt;/my:Menu&gt;
  </code></pre>
  
  <p>Which Attributes are missing/wrong? I've looked into ListBox, which also parses child items an I have the feelding that my control is doing the same.</p>
  
  <p>The only differences I've found:</p>
  
  <ul>
  <li>I am using a generic List, ListBox has it's own collection type for ListItems</li>
  <li>I have no Editor or ControlBuilder or TypeConverter for my MenuItem, ListBox does.</li>
  </ul>
  
  <p>This is not a control I'm willing to sell, it's only for me. I don't need any Editor or Desinger, I'm writing HTML/ASP.NET markup by hand.</p>
  
  <p>I am using Visual Studio 2008, .NET 3.5.</p>
  
  <p>Thanks for any Hints, Help or Sulutions!</p>