How to use OnTick event in Timer control in asp.net ajax

Ajax Timer OnTick event
UsingTimerOnTickEvent.aspx

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Drawing" %>

<!DOCTYPE html>
<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadioButtonList1.Font.Name = "Comic Sans MS";
            RadioButtonList1.Font.Size = FontUnit.Medium;
            RadioButtonList1.SelectedIndex = 0;
            RadioButtonList1.ForeColor = Color.FromName(RadioButtonList1.SelectedItem.Text);
        }
    }
    protected void Timer1_Tick(object sender, System.EventArgs e)
    {
        int selectedIndex = RadioButtonList1.SelectedIndex;
        int totalIndex = RadioButtonList1.Items.Count -1;
        if (selectedIndex == totalIndex)
        {
            RadioButtonList1.SelectedIndex = 0;
        }
        else
        {
            RadioButtonList1.SelectedIndex = selectedIndex + 1;
        }
        RadioButtonList1.ForeColor = Color.FromName(RadioButtonList1.SelectedItem.Text);
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Ajax Timer OnTick event - How to use OnTick event in Timer control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:DarkBlue; font-style:italic;">Ajax Timer Example: How To Use OnTick Event</h2>
        <hr width="450" align="left" color="CornFlowerBlue" />
        <br /><br />
        <asp:ScriptManager 
            ID="ScriptManager1"
            runat="server"
            >
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:RadioButtonList 
                    ID="RadioButtonList1"
                    runat="server"
                    BorderColor="Salmon"
                    BorderWidth="1"
                    RepeatColumns="3"
                    >
                    <asp:ListItem>Crimson</asp:ListItem>                    
                    <asp:ListItem>RosyBrown</asp:ListItem>                    
                    <asp:ListItem>IndianRed</asp:ListItem>                    
                    <asp:ListItem>Maroon</asp:ListItem>                    
                    <asp:ListItem>DodgerBlue</asp:ListItem>                    
                    <asp:ListItem>SeaGreen</asp:ListItem>                    
                </asp:RadioButtonList>
                <asp:Timer 
                    ID="Timer1"
                    runat="server"
                    Interval="4000"
                    OnTick="Timer1_Tick"
                    >
                </asp:Timer>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
Related asp.net ajax examples