<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Checkout" %>
Chapter 20: Checkout MultiView
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Checkout : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int year = DateTime.Now.Year;
for (; year < DateTime.Now.Year + 6; year++)
ddlExpirationYear.Items.Add(year.ToString());
}
}
protected void btnFinish_Click(object sender, EventArgs e)
{
this.DisplayMessage();
}
private void DisplayMessage()
{
string shipVia = "";
if (rdoUPSGround.Checked)
shipVia = "UPSG";
else if (rdoUPS2Day.Checked)
shipVia = "UPS2D";
else if (rdoFedEx.Checked)
shipVia = "FEDEX";
string message =
"Contact info\n" +
" First name: " + txtFirstName.Text + "\n" +
" Last name: " + txtLastName.Text + "\n" +
" Email: " + txtEmail.Text + "\n" +
"Shipping method\n" +
" Ship via: " + shipVia + "\n" +
"Credit card info\n" +
" Type: " + listCardType.SelectedValue + "\n" +
" Number: " + txtCardNumber.Text + "\n" +
" Expiration date: " + ddlExpirationMonth.SelectedValue + "/"
+ ddlExpirationYear.SelectedValue;
txtMessage.Text = message;
}
}