Custom Controls ASP.Net Tutorial

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

    void Page_Load()
    {
        List quotes = new List();
        quotes.Add("A");
        quotes.Add("B");
        quotes.Add("C");
        Random rnd = new Random();
        lblQuote.Text = quotes[rnd.Next(quotes.Count)];
    }





    


    
            id="lblQuote"
        Runat="server" />
    



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


    
        .quote
        {
            width:200px;
            padding:20px;
            border:Dotted 2px orange;
            background-color:#eeeeee;
            font:16px Georgia,Serif;
        }
    
    Show Random Quotation


    
    

    <%= DateTime.Now %>
    
            id="RandomQuotation1"
        Runat="server" />
    

    


File: Web.Config