To Projects

IT 230 -- Project 2
Images for Time and Month

  1. Create an ASP.Net page (.aspx extension) that displays the following:
     
    1. Current time and date obtained from the DateTime object displayed in a Literal control.
       
    2. An image of the sun if the time is between 6:00am and 6:00pm. An image of the moon if the time is between 6:00pm and 6:00am.
       
    3. The name of the current month displayed in a Literal control.
       
    4. An image representing the current month. Choose from these images or choose your own month images if you prefer:
       
    5. Be sure to upload the sun, moon, and month images to ectweb2 when you upload your .aspx file. Do not submit your images with your source code .txt or .zip file.
       
    6. Include a document-level style or link to external style page to set the colors and fonts on the page.
       
    7. Use Examples 12 (temperature-descriptors1.aspx) and 17 (flintstones.aspx) to help you with this project.
       
    8. Update your index page to include a link to your Project 2 submission. Finish your index page if you did not include one for Project 1.
       
    9. Hints and recommendations:
       
      • If you want to rename a webpage in Visual Studio, rename the page using the Solution Explorer. Do not simply rename the file using Windows Explorer. This will corrupt the project.
         
      • You don't have to wait until a Visual Studio project is completely debugged to move the C# code from the code-behind file to the .aspx file in script tags. You can move the C# code as soon as you wish, then continue to work on the project.
         
      • For a webpage to find images in a Visual Studio project, the images must be added to the project. Put the images in the same folder as the .aspx file that will access the images. Then add each image to the project like this: main menu Project >> Add Existing Item >> double click on the image.
         
      • Put all your code for Project 2 in a Page_Load event handler. You can obtain the header for this event handler in Visual Studio by going to Design mode and double clicking on the page, but not on any control. Here is the header produced:
        protected void Page_Load(object sender, EventArgs e)
        {
        
        }
        
      • Here is how to obtain the current date and time and display them in the Literal control litDateTime using C#:
        DateTime d = DateTime.Now;
        litDateTime.Text = d.ToString( );
        
      • Use this if statement for deciding which image to display for the hour. d represents a DateTime object that contains the current date (see previous hint):
        if (d.Hour >= 6 && d.Hour <= 18)
        {
            // display the sun image.
        }
        else
        {
            // display the moon image.
        }
        
      • Here is suggested pseudocode for the event handler:
        public void Page_Load(object sender, EventArgs e)
        {
            Declare variables.
            Get current date.
            Display current date.
            if time is between 6:00 and 18:00,
                show sun image.
            else
                show moon image.
            Use if..else statement to display month name
                 and month image depending on value of d.Month.
        }