Custom Controls ASP.Net Tutorial

File: Control.ascx
<%@ Control Language="C#" ClassName="TabStrip" %>
<%@ Import Namespace="System.Collections.Generic" %>

    public event EventHandler TabClick;
    public int SelectedIndex
    {
        get { return dlstTabStrip.SelectedIndex; }
    }
    void Page_Load()
    {
        if (!Page.IsPostBack)
        {
            List tabs = new List();
            tabs.Add("A");
            tabs.Add("B");
            tabs.Add("C");
            dlstTabStrip.DataSource = tabs;
            dlstTabStrip.DataBind();
            dlstTabStrip.SelectedIndex = 0;
        }
    }
    protected void dlstTabStrip_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (TabClick != null)
            TabClick(this, EventArgs.Empty);
    }

    id="dlstTabStrip"
    RepeatDirection="Horizontal"
    OnSelectedIndexChanged="dlstTabStrip_SelectedIndexChanged"
    CssClass="tabs"
    ItemStyle-CssClass="tab"
    SelectedItemStyle-CssClass="selectedTab"
    Runat="server">
    
            id="lnkTab"
        Text='<%# Container.DataItem %>'
        CommandName="Select"
        Runat="server" />
    


File: Default.aspx
<%@ Page Language="C#" %>
<%@ Register TagPrefix="user" TagName="TabStrip" Src="~/Control.ascx" %>
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    protected void TabStrip1_TabClick(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex = TabStrip1.SelectedIndex;
    }



    
        .tabs a
        {
            color:blue;
            text-decoration:none;
            font:14px Arial,Sans-Serif;
        }
        .tab
        {
            background-color:#eeeeee;
            padding:5px;
            border:Solid 1px black;
            border-bottom:none;
        }
        .selectedTab
        {
            background-color:white;
            padding:5px;
            border:Solid 1px black;
            border-bottom:none;
        }
        .views
        {
            background-color:white;
            width:400px;
            border:Solid 1px black;
            padding:10px;
        }
    
    Show TabStrip


    
    

            ID="TabStrip1"
        OnTabClick="TabStrip1_TabClick"
        Runat="Server" />
    
            id="MultiView1"
        ActiveViewIndex="0"
        Runat="server">
        
            

Products


            We sell a variety of useful products...
        
        
            

Services


            We offer a number of services...
        
        
            

About


            We were the first company to offer products and services...