App_Code\ComputerOrder.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
///
/// Summary description for ComputerOrder
///
public class ComputerOrder
{
public ComputerOrder()
{
//
// TODO: Add constructor logic here
//
}
private string brand;
public string Brand
{
get { return brand; }
set { brand = value; }
}
private string computerType;
public string ComputerType
{
get { return computerType; }
set { computerType = value; }
}
private string hardDiskSize;
public string HardDiskSize
{
get { return hardDiskSize; }
set { hardDiskSize = value; }
}
}
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Computer order form</h1>
<!--this is a comment-->
<p><asp:Label ID="Label1" runat="server" Text="Computer Brand "></asp:Label>
<asp:TextBox ID="txtBrand" runat="server"></asp:TextBox></p>
<asp:Label ID="Label2" runat="server" Text="choose Type"></asp:Label><!--this is a simple form-->
<asp:RadioButtonList ID="rdoType" runat="server">
<asp:ListItem>Laptop</asp:ListItem>
<asp:ListItem>Desktop</asp:ListItem>
</asp:RadioButtonList>
<asp:Label ID="Label3" runat="server" Text="Hard Disk size" ></asp:Label>
<asp:DropDownList ID="ddlHardDisk" runat="server">
<asp:ListItem>250 Gigs</asp:ListItem>
<asp:ListItem>350 Gigs</asp:ListItem>
<asp:ListItem>500 Gigs</asp:ListItem>
</asp:DropDownList><br />
</div><asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
</form>
</body>
</html>
Default.aspx.cs
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)
{
ComputerOrder myComputerOrder = new ComputerOrder();
myComputerOrder.Brand = txtBrand.Text;
myComputerOrder.ComputerType =
rdoType.SelectedValue.ToString();
myComputerOrder.HardDiskSize =
ddlHardDisk.SelectedValue.ToString();
Session["order"] = myComputerOrder;
Response.Redirect("Default2.aspx");
}
}
Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Confirm your order</h1>
<p><asp:Label ID="Label1" runat="server" Text="Brand: "></asp:Label>
<asp:Label ID="lblBrand" runat="server" Text="" CssClass="sample"></asp:Label><br />
<asp:Label ID="Label2" runat="server" Text="Type: "></asp:Label>
<asp:Label ID="lblType" runat="server" Text="" CssClass="sample"></asp:Label><br />
<asp:Label ID="Label3" runat="server" Text="Hard Disk: "></asp:Label>
<asp:Label ID="lblHardDisk" runat="server" Text="" CssClass="sample"></asp:Label></p>
<asp:Button ID="Button1" runat="server" Text="Confirm"
onclick="Button1_Click" />
</div>
</form>
</body>
</html>
Default2.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["order"] != null)
{
ComputerOrder confirmOrder = (ComputerOrder)Session["order"];
lblBrand.Text = confirmOrder.Brand;
lblType.Text = confirmOrder.ComputerType;
lblHardDisk.Text = confirmOrder.HardDiskSize;
}
else
{
Response.Redirect("Default.aspx");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
StyleSheet.css
body {
}
h1
{
color:Navy;
}
.sample
{
color:Red;
}
No comments:
Post a Comment