Hello, I need help for this home work C# language . ASP.NET and Visual Studio Gr
ID: 3872000 • Letter: H
Question
Hello,
I need help for this home work C# language .
ASP.NET and Visual Studio Graduation Age
This assignment will serve as an exercise to establish and confirm the proper configuration and installation of ASP.NET development environment (Visual Studio, IIS and IE.) This assignment is to be ‘Projectless’.
*A Page with Active Contentc
Create an ASP.NET content page that calculates a student’s age at graduation. Your web page will accept a student’s date of birth and a date of graduation and will display the student’s age at graduation.
Include the following:
A page_load event that will get the current date for display
Six text boxes to accept the student’s birth and graduation year, month and day
A command button with underlying code that will calculate the student’s age at graduation
A label that will present the age to the user
A banner image
A title specification
*Making a Projectless Website
Start VS.
Choose File>New>Website.
Select .NET Framework 4.5 (note you may have to change to a down-level version when publishing to your service provider)
Select the ASP.NET Empty Website template
Specify a location for the website code and click OK
To turn in your assignments, publish your website to your service provider (you will want to create a subdirectory on your server for this.) The files required to be on your server are:
Default.aspx
Default.aspx.cs
Web.config You may want to use the web.config available on ( https://files.fm/u/78mswwzz )
You can see this image for example ( https://files.fm/u/npkkzz99 )
Thank you
Explanation / Answer
Here I have created banner image using AdRotator control of ASP.Net. For that you need to create a folder named banner in which put your all images and xml file which contains the datasource of that ad rotator.
Default.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Banner Image Demo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Height="58px">
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="bannerImage" />
<asp:XmlDataSource ID="bannerImage" runat="server" DataFile="~/Banners/Ads.xml"></asp:XmlDataSource>
</asp:Panel>
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<p>
<asp:Label ID="Label2" runat="server" Text="Enter Birth Year/Month/Date"></asp:Label>    
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> 
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label3" runat="server" Text="Enter Graduation Year/Month/Date"></asp:Label> 
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox> 
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox> 
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox> 
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="Calculate Age" />
</p>
<p>
<asp:Label ID="Label4" runat="server" Text="Age" Enabled="False"></asp:Label>    
<asp:Label ID="Label5" runat="server" Text="Label" Enabled="False"></asp:Label>
</p>
<p>
</p>
</form>
</body>
</html>
Default.aspx.cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DateTime today = DateTime.Today; // fetching the today's date
Label1.Text = today.ToString(); // assigning that value to the label to display
}
protected void Button1_Click(object sender, EventArgs e)
{
//converts the entered date in DateTime object
DateTime birth = new DateTime(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text), Convert.ToInt32(TextBox3.Text));
DateTime graduate = new DateTime(Convert.ToInt32(TextBox4.Text), Convert.ToInt32(TextBox5.Text), Convert.ToInt32(TextBox6.Text));
var age = graduate.Year - birth.Year;
if (birth > graduate.AddYears(-age)) age--;
Label5.Text = age.ToString();
Label4.Enabled = true; //enabling the age displayed label
Label5.Enabled = true;
}
}
Datasource for ad rotator that is Ads.xml file
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>~/Banners/image1.JPG</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>Google</AlternateText>
<Keyword>Google, search engine</Keyword>
<Impression>6</Impression>
</Ad>
<Ad>
<ImageUrl>~/Banners/image2.JPG</ImageUrl>
<NavigateUrl>http://www.facebook.com</NavigateUrl>
<AlternateText>Facebook</AlternateText>
<Keyword>facebook, social media</Keyword>
<Impression>5</Impression>
</Ad>
</Advertisements>
Here I have created ad for google.com and facebook.com. You can create your own.
In this data file
ImageURL Specifies the url of image that will be loaded
NavigateUrl when user clicks on that ad, he will be redirected to that page
AlternateText Shows the text when the image can not be loaded for any reason when you hover on that ad
Keyword gives the keyword. You can filter the ad based on that keyword
Impression specifies how many number of time you want to show that particular ad. It can be same or different.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.