Using Switch for displaying images

Hi
can anyone help with this problem, I want to display images depending on the time of year
i.e summer, winter, christmas, easter.

Does anyone know how I can set up the code so that I can achieve this.
My variables are:
StartSummerTime = Convert.ToDateTime("28/03/2004 01:00:00");
EndSummerTime = Convert.ToDateTime("31/10/2004 02:00:00");
StartWinterTime = Convert.ToDateTime("31/10/2004 02:00:01");
EndWinterTime= Convert.ToDateTime("28/03/2004 00:59:00");
ChristmasTime = Convert.ToDateTime("25/12/2004 00:00:00");
EasterTime = Convert.ToDateTime("11/04/2004 00:00:00");

Any help would be appreciated
caz
BeginningWebDesignAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

smeggheadCommented:
           DateTime TestTime;
            TestTime=new DateTime(2004,5,25); // Set this to today's date as below
            //TestTime=DateTime.Now;
            string TestString=TestTime.ToString("MMddHH");
            if (TestString.StartsWith("1225")) Console.WriteLine("X-mas");
            else if (TestString.StartsWith("0411")) Console.WriteLine("Easter");
            else if ((TestString.CompareTo("032801")>0) && (TestString.CompareTo("103102")<0)) Console.WriteLine("Summer");
            else Console.WriteLine("Winter");
            Console.ReadLine();
0
dsaboCommented:
DateTime EvalTime = DateTime.Now


if(EvalTime == ChristmasTime )
{
    //chrismas
}
else if(EvalTime == EasterTime )
{
    //easter
}
else if((StartSummerTime  <= EvalTime) && (EvalTime <= EndSummerTime ))
{
     //summer
}
else if((StartWinterTime <= EvalTime) && (EvalTime <= EndWinterTime))
{
    //winter
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BeginningWebDesignAuthor Commented:
Hi dsabo

I have got your code to work, except how do I display the images below:

<asp:Image ID="SummerScene" ImageUrl="images/summer.jpg" runat="server"/>
<asp:Image ID="SummerScene" ImageUrl="images/winter.jpg" runat="server"/>
<asp:Image ID="SummerScene" ImageUrl="images/christmas.jpg" runat="server"/>
<asp:Image ID="SummerScene" ImageUrl="images/easter.jpg" runat="server"/>


if(EvalTime == ChristmasTime )
{
    DisplayImage.Text = "What goes here";
}
else if(EvalTime == EasterTime )
{
    //easter
}
else if((StartSummerTime  <= EvalTime) && (EvalTime <= EndSummerTime ))
{
    DisplayImage.Text =  "summer";
}
else if((StartWinterTime <= EvalTime) && (EvalTime <= EndWinterTime))
{
    DisplayImage.Text = "winter";
}
}

Body text ***********************
<asp:Label id="DisplayImage" runat="server"/>

Thanks
Caz
0
dsaboCommented:
Try using this:



if(EvalTime == ChristmasTime )
{
    SummerScene.ImgaeUrl = "images/summer.jpg";
}


I'dont have the IDE at this moment, just give it a try.
0
smeggheadCommented:
dsabo,

If it is in the middle of xmas day, your check will show as Winter.

Smg.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.