.net 3,4
Online mobile shop
Site1.Master
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"
Inherits="OnlineMobilePhoneShop.Site1" %>
<!DOCTYPE html>
<html>
<head>
<title>Online Mobile Phone Shop</title>
<link rel="stylesheet" type="text/css" href="Styles.css" />
</head>
<body>
<form id="Form1" runat="server">
<div class="header">
<h1>Online Mobile Phone Shop</h1>
<nav>
<a href="Default.aspx">Home</a> |
<a href="Product.aspx">Products</a> |
<a href="Cart.aspx">Cart</a>
</nav>
</div>
<asp:ContentPlaceHolder ID="MainContent"
runat="server"></asp:ContentPlaceHolder>
<div class="footer">© 2025 Online Mobile Shop</div>
</form>
</body>
</html>
Default.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="OnlineMobilePhoneShop.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Welcome to the Online Mobile Shop</h2>
<p>Find the best mobile phones at the best prices.</p>
</asp:Content>
Cart.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
CodeBehind="Cart.aspx.cs" Inherits="OnlineMobilePhoneShop.WebForm3" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Your Shopping Cart</h2>
<asp:Label ID="lblCart" runat="server" Text="Your Cart is Empty..."></asp:Label>
</asp:Content>
Product.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
CodeBehind="Cart.aspx.cs" Inherits="OnlineMobilePhoneShop.WebForm3" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<h2>Your Shopping Cart</h2>
<asp:Label ID="Label1" runat="server" Text="Your Cart is Empty..."></asp:Label>
</asp:Content>
Cart.aspx.cs
using System;
using System.Web.UI;
namespace OnlineMobilePhoneShop
{
public partial class WebForm3 : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Cart"] != null)
{
lblCart.Text= "Your Cart: " + Session["Cart"].ToString();
}
else
{
lblCart.Text = "Your cart is empty.";
}
}
}
}
Product.aspx.cs
using System;
using System.Web.UI;
namespace OnlineMobilePhoneShop
{
public partial class WebForm2 : Page
{
protected void btnAddToCart_Click(object sender, EventArgs e)
{
if (lstProducts.SelectedItem != null)
{
Session["Cart"] = lstProducts.SelectedItem.Text;
Response.Redirect("Cart.aspx");
}
}
}
}
Styles.css
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
text-align: center;
}
.header {
background: #004080;
color: white;
padding: 15px;
}
.footer {
background: #222;
color: white;
padding: 10px;
position: absolute;
bottom: 0;
width: 100%;
}
nav a {
color: white;
text-decoration: none;
margin: 0 10px;
}
Comments
Post a Comment