Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my website, an image is needed to show and should change periodically .
I used the below code.

XML
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" OnTick="gettickvalue" Interval="2000">
</asp:Timer>
<asp:UpdatePanel ID="BannerPanel" runat="server" UpdateMode="Conditional">
<Triggers >
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Image ID="imgBanner" ImageUrl="~/images/banner_1.gif" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>




In the code section add the following lines.

C#
protected void gettickvalue(object sender, EventArgs e)
{
Random RandomNumber = new Random();
int n = RandomNumber.Next(1, 9);
imgBanner.ImageUrl = System.String.Concat("images/banner_", n.ToString(), ".gif");
}

*------*
But I can see in first a image is showing, after particular time delay image changed but immediately come another .So Can't see any image.
I increased interval to 5000 or above , but it is changed image coming time only.
How can set image appear 5-6 seconds .
Posted
Updated 9-May-11 21:59pm
v2

http://www.4guysfromrolla.com/articles/091907-1.aspx[^]

Please read this article I think it will help you
 
Share this answer
 
try to set it to 50000 or 60000 since the time is in millisec.
 
Share this answer
 
My files are in not in gif format. All files are jpg format. I changed type to jpg . Then files showing correctly
 
Share this answer
 
Comments
Sandeep Mewara 10-May-11 5:57am    
Is this an answer to your issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900