Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
i want to put a standard image control on my website , that will be able to show  8 photos by using a standard label and the ajax timer control , ( as Example : the first photo appears at 12:00 am , the second photo appears at 01:00 am , this time will be the text of the label and the photos will be changed by label's text changing ... )all this photo have the same extensions and will appear by the same image control ... If you please , tell me what should i do here ,
this code is as a try :
<pre lang="c#">
        Random _rand = new Random();
        if (Label1.Text == "12:00 am")
        {
            Image1.ImageUrl = "`/Pics2/1.jpg";
            int i = _rand.Next(1, 8);
            Image1.ImageUrl = "`/Pics2/" + i.ToString() + ".jpg";
        }
</pre>
and that is another try :
<pre lang="c#">
switch (Label1.Text)
        {
            case "08:55 ص":
                Image1.ImageUrl = "`/Pics2/1.jpg";
                break;
            case "08:56 ص":
                Image1.ImageUrl = "`/Pics2/2.jpg";
                break;
            case "08:57 ص":
                Image1.ImageUrl = "`/Pics2/2.jpg";
                break;

        }
</pre>

as a note : that code was written by c# , and the controls is coded by asp.net
(that label was inserted like that ) :
 <asp:UpdatePanel>
     <ContentTemplate>
        <asp:Label ID="Label1" runat="server"></asp:Label>
     </ContentTemplate>
     <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
     </Triggers>
</asp:UpdatePanel> 
( and the image was inserted like that ) :
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
     <ContentTemplate>
          <asp:Image ID="Image1" runat="server" Height="100px" 
          Width="100px" />
     </ContentTemplate>
     <Triggers>
          <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
     </Triggers>
</asp:UpdatePanel>

thanks very much , and sorry for long question , waiting your response ...
Posted
Updated 5-Aug-13 2:41am
v2
Comments
Sergey Alexandrovich Kryukov 23-Jul-13 13:01pm    
I would rather say: bad idea. Why? why?!
—SA
prof-mohamed atef 23-Jul-13 13:03pm    
why is it a bad idea , can you give me the good of you please !?
Sergey Alexandrovich Kryukov 23-Jul-13 13:15pm    
What's good in it? You want to do some modifications out of user's control, by a timer, which would look confusing at best. Nothing can guarantee that the processing of the timer even is always complete before the next event. A lot of problems, and for what? It is showing something like a slide show? There are a number of slide show samples around...
—SA
prof-mohamed atef 23-Jul-13 13:58pm    
let's give me one of the slide show samples that change photos by itself with a determined time
Sergey Alexandrovich Kryukov 23-Jul-13 14:34pm    
You can easily find many by yourself, as this is a popular topic, bit... first, will you tag the application type you want to have?
—SA

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