ASP.net custom user control design I've built a custom control that generates a tab style navigation.  Each page might have different tabs to display, the aim was to modularise it so I can make global changes to all the tabs.

TabMenu.ascx

&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="TabMenu.ascx.cs" Inherits="TabMenu" %&gt;

&lt;asp:Panel runat="server" ID="TabMenuWrapper" CssClass="tabWrapper"&gt;

&lt;/asp:Panel&gt;


TabMenu.ascx.cs

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

public partial class TabMenu : System.Web.UI.UserControl
{
    public string TabGroup { get; set; }    // The tab group this control belongs to
    public int SelectedTab { get; set; }    // Index of selected tab

    protected void Page_Load(object sender, EventArgs e)
    {
        ArrayList tabCollection = new ArrayList();
        MenuTab myTab;

        // Artorking tab group
        if (this.TabGroup.ToLower() == "artwork")
        {
            myTab = new MenuTab() { linkURL = "artworkHome.aspx", linkText = "First!" };
            tabCollection.Add(myTab);

            myTab = new MenuTab() { linkURL = "artworkHome.aspx", linkText = "Second!" };
            tabCollection.Add(myTab);

            myTab = new MenuTab() { linkURL = "artworkHome.aspx", linkText = "3rd!" };
            tabCollection.Add(myTab);

            myTab = new MenuTab() { linkURL = "artworkHome.aspx", linkText = "Fourth!" };
            tabCollection.Add(myTab);            
        }

        // Add tabs to the page
        for (int i = 0; i &lt; tabCollection.Count; i++)
        {
            MenuTab thisTab = ((MenuTab)(tabCollection[i]));
            thisTab.CreateTab();

            if (i == this.SelectedTab)
            {
                thisTab.tabPanel.CssClass = "tab tabSelected";
            }

            TabMenuWrapper.Controls.Add(thisTab.tabPanel);
        }
        TabMenuWrapper.Controls.Add(new Panel(){CssClass = "clear"});

    }
}

// A menu tab
public class MenuTab
{
    public string linkURL;
    public string linkText;
    public HyperLink tabLink;
    public Panel tabPanel;

    // Create internal controls
    public void CreateTab()
    {
        this.tabLink = new HyperLink() { NavigateUrl = this.linkURL, Text = this.linkText };
        this.tabPanel = new Panel() { CssClass = "tab" };
        this.tabPanel.Controls.Add(this.tabLink);
    }
}


Used as follows:

&lt;CrystalControls:TabMenu runat="server" ID="TopMenu" TabGroup="Artwork" SelectedTab="1" /&gt;


And renders like:

&lt;div class="tab"&gt;

  &lt;a href="Controls/artworkHome.aspx"&gt;First!&lt;/a&gt;

 &lt;/div&gt;&lt;div class="tab tabSelected"&gt;

  &lt;a href="Controls/artworkHome.aspx"&gt;Second!&lt;/a&gt;

 &lt;/div&gt;&lt;div class="tab"&gt;

  &lt;a href="Controls/artworkHome.aspx"&gt;3rd!&lt;/a&gt;

 &lt;/div&gt;&lt;div class="tab"&gt;

  &lt;a href="Controls/artworkHome.aspx"&gt;Fourth!&lt;/a&gt;

 &lt;/div&gt;&lt;div class="clear"&gt;



 &lt;/div&gt;

&lt;/div&gt;


Is this a good design?
It might be better to render the control as an unordered list.  This is more semantically correct and normal practice for menu-type controls (which tabs are, if you think about it).