Skip to content

Instantly share code, notes, and snippets.

@esmyth01
Created January 6, 2016 19:52
Show Gist options
  • Save esmyth01/8a43ba9d7d6c6318804a to your computer and use it in GitHub Desktop.
Save esmyth01/8a43ba9d7d6c6318804a to your computer and use it in GitHub Desktop.
Assignment 1 itc172
<%@ 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></title>
<link href="HelloAsp.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Assignment 1</h1>
<p>Select your birthday!</p>
<asp:Calendar ID="Calendar" runat="server"></asp:Calendar>
<p>Enter your name</p>
<asp:TextBox ID="TextName" runat="server"></asp:TextBox>
<asp:Label ID="LabelHello" runat="server" Text="" CssClass="result"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Submit Data" OnClick="Button1_Click" />
<asp:Label ID="FinalResult" runat="server" Text="" CssClass="result"></asp:Label>
</div>
</form>
</body>
</html>
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)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
DateTime birthdate = Calendar.SelectedDate;
string name = TextName.Text;
DateTime today = DateTime.Now;
string daysUntilBirthday = birthdate.Subtract(today).TotalDays.ToString("###");
FinalResult.Text = "Hello " + name + " your birthday is June 8, " + " you have " + daysUntilBirthday + " until your birthday!";
}
}
body {
}
h1 {
color: aqua;
font-family: Arial;
font-weight: 900;
}
.result {
color: green;
margin-left: 40px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment