File: Default.aspx
<%@ Page language="c#" Inherits="GreetingCardMaker" CodeFile="Default.aspx.cs" %>
Greeting Card Maker
File: Default.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class GreetingCardMaker : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (this.IsPostBack == false)
{
lstBackColor.Items.Add("White");
lstBackColor.Items.Add("Red");
lstBackColor.Items.Add("Green");
lstBackColor.Items.Add("Blue");
lstBackColor.Items.Add("Yellow");
lstFontName.Items.Add("Times New Roman");
lstFontName.Items.Add("Arial");
lstFontName.Items.Add("Verdana");
lstFontName.Items.Add("Tahoma");
ListItem item = new ListItem();
item.Text = BorderStyle.None.ToString();
item.Value = ((int)BorderStyle.None).ToString();
lstBorder.Items.Add(item);
item = new ListItem();
item.Text = BorderStyle.Double.ToString();
item.Value = ((int)BorderStyle.Double).ToString();
lstBorder.Items.Add(item);
item = new ListItem();
item.Text = BorderStyle.Solid.ToString();
item.Value = ((int)BorderStyle.Solid).ToString();
lstBorder.Items.Add(item);
lstBorder.SelectedIndex = 0;
imgDefault.ImageUrl = "default.png";
}
}
protected void cmdUpdate_Click(object sender, System.EventArgs e)
{
pnlCard.BackColor = Color.FromName(lstBackColor.SelectedItem.Text);
lblGreeting.Font.Name = lstFontName.SelectedItem.Text;
try
{
if (Int32.Parse(txtFontSize.Text) > 0)
{
lblGreeting.Font.Size = FontUnit.Point(Int32.Parse(txtFontSize.Text));
}
}catch {
}
pnlCard.BorderStyle = (BorderStyle)Int32.Parse(lstBorder.SelectedItem.Value);
if (chkPicture.Checked == true)
{
imgDefault.Visible = true;
}else {
imgDefault.Visible = false;
}
lblGreeting.Text = txtGreeting.Text;
}
}