Thursday, January 17, 2013

Assignment 2 Example

here is the master page

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Community Assist</title>

    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="CommunityAssist.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <h1>Community Assist</h1>
    <form id="form1" runat="server">
    <div>

        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Here is the Default content page

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <!--This is the body content-->
    <h2>Make A Donation</h2>
    <table>
        <tr>
            <td>Enter First Name</td>
            <td>
                <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox></td>
            <td></td>
        </tr>
         <tr>
            <td>Enter Last Name</td>
            <td>
                <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox></td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtLastName" ErrorMessage="Last Name is required"></asp:RequiredFieldValidator>
             </td>
        </tr>
         <tr>
            <td>Enter Street Address</td>
            <td>
                <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox></td>
            <td></td>
        </tr>
         <tr>
            <td>Enter City</td>
            <td>
                <asp:TextBox ID="txtCity" runat="server"></asp:TextBox></td>
            <td></td>
        </tr>
         <tr>
            <td>Enter State</td>
            <td>
                <asp:TextBox ID="txtState" runat="server"></asp:TextBox></td>
            <td></td>
        </tr>
         <tr>
            <td>Enter Zip Code</td>
            <td>
                <asp:TextBox ID="txtZip" runat="server"></asp:TextBox></td>
            <td></td>
        </tr>
         <tr>
            <td>Enter Email</td>
            <td>
                <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox></td>
            <td></td>
        </tr>
         <tr>
            <td>Enter Phone</td>
            <td>
                <asp:TextBox ID="txtPhone" runat="server"></asp:TextBox></td>
            <td></td>
        </tr>
         <tr>
            <td>Enter DonationAmount</td>
            <td>
                <asp:TextBox ID="txtDonation" runat="server"></asp:TextBox></td>
            <td></td>
        </tr>
         <tr>
            <td>
                <asp:Button ID="btnSubmit" runat="server" Text="Submit" /></td>
            <td>
                <asp:Label ID="lblMessage" runat="server" Text="Label"></asp:Label>
                </td>
            <td></td>
        </tr>
    </table>
</asp:Content>


Here is the Donor Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// 
/// Summary description for Donor
/// 
public class Donor
{
    //private variables
    private string lastName;
    private string firstName;
    private string address;
    private string city;
    private string state;
    private string zip;
    private string email;
    private string phone;
    private double donationAmt;

    #region public properties
    public string LastName
    {
        get { return lastName; }
        set { lastName = value; }
    }

    public string Address
    {
        get { return address; }
        set { address = value; }
    }


    public string City
    {
        get { return city; }
        set { city = value; }
    }


    public string State
    {
        get { return state; }
        set { state = value; }
    }


    public string Zip
    {
        get { return zip; }
        set { zip = value; }
    }


    public string Email
    {
        get { return email; }
        set { email = value; }
    }


    public string Phone
    {
        get { return phone; }
        set { phone = value; }
    }


    public double DonationAmt
    {
        get { return donationAmt; }
        set { donationAmt = value; }
    }

    public string FirstName
    {
        get
        {
            return firstName;
        }
        set
        {
            firstName = value;
        }
    }
#endregion

    public Donor()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    //public property
}

Here is the webConfig file

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

    <system.web>
      <compilation debug="false" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
  </appSettings>

</configuration>

Here is the style sheet

body {
}

h1 {
    background-color:navy;
    color:white;
    border:solid 5px black;
    text-align:center;
}

No comments:

Post a Comment