5
Answers

image change on timer tick

kshama parashar

kshama parashar

14y
7.8k
1
hello to all
i want to repeat the all four image on single image on timer tick

my code:

jewel.aspx:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
       
        <asp:Image ID="ImageButton1" runat="server" ImageUrl="image/1.gif" />
        <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick">
        </asp:Timer>
       
    </div>
    </form>
</body>
</html>

jewel.aspx.cs:

  string[] aa = new string[4]; 
    protected void Page_Load(object sender, EventArgs e)
    {

        aa[0] = "image/1.gif";
        aa[1] = "image/2.gif";
        aa[2] = "image/3.gif";
        aa[3] = "image/4.gif";
       
        
       
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {


        chang();
       
            

        
    }

    public void chang()
    {
        for (int i = 0; i <= 3; i++)
        {
            ImageButton1.ImageUrl = aa[i];
        }
    }


it showing only first and last image


Answers (5)