title: Can I create custom directives in ASP.NET?
body: <p>I have created a menu control in asp.net and have put it into master page. This menu control have property ActiveItem which when modified makes one or another item from menu appear as active.</p>
  
  <p>To control active item from child page I have created a control which modifies master page property enforced by IMenuContainer interface to update menu control's active item in master page.</p>
  
  <pre><code>public class MenuActiveItem : Control
  {
      public ActiveItemEnum ActiveItem
      {
          get
          {
              var masterPage = Page.Master as IMenuContainer;
              if (masterPage == null)
                  return ActiveItemEnum.None;
  
              return masterPage.ActiveItem;
          }
  
          set
          {
              var masterPage = Page.Master as IMenuContainer;
              if (masterPage == null)
                  return;
  
              masterPage.ActiveItem = value;
          }
      }
  }
  </code></pre>
  
  <p>Everything works perfectly and I really enjoy this solution, but I was thinking that, if I knew how, I would have created a custom directive with same feature instead of custom control because it just makes more sense that way.</p>
  
  <p>Does anybody know how to do it?</p>