Tuesday, April 7, 2015

First ASP

the Default web page

<%@ 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="FirstAspStyle.css" rel="stylesheet" type="text/css" />
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <p>Choose your birthday</p>
        <!--add an asp calendar control-->
        <asp:Calendar ID="CalendarFirst"  
             runat="server" ></asp:Calendar>
        <p>
        <asp:Label ID="Label1" runat="server" 
            Text="Enter Your Name"></asp:Label>
        <asp:TextBox ID="txtName" 
            runat="server" CssClass="textback"></asp:TextBox></p>
        <p>
        <asp:Button ID="Button1" 
            runat="server" Text="Get Days" OnClick="Button1_Click" />
        <asp:Label ID="lblResult" runat="server" 
            Text=""></asp:Label>

        </p>
    </div>
    </form>
</body>
</html>

The C# code behind

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
{
    /* this is a multi line
     * comment
     */


    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //take the value from the text box
        //and assign it to the variable name
        string name = txtName.Text;
        string birthDate = CalendarFirst.SelectedDate.ToShortDateString();
        lblResult.Text = "Hello, " + name + " Your birthday is " + birthDate;
      
    }
}

Here is the CSS

body {
}

table tr th{
    font-weight:bold;
    background-color:aliceblue;
    border :5px solid black;
}

.textback{
    background-color:yellow;
}


No comments:

Post a Comment