Step 1: Create the ASP.NET Web Application
Open Visual Studio → Create New Project → ASP.NET Web Application (.NET Framework).
Name it: EmployeeManagementSystem.
Select Web Forms → Click Create.
Step 2: Create the Master Page
Add → New Item → Master Page → Name: Site1.Master
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="employee.Site1" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<title>Employee Management System</title>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<!-- Header -->
<div class="header">
<h1>Employee Management System</h1>
<nav>
<a href="Default.aspx">Home</a> |
<a href="AddEmployee.aspx">Add Employee</a> |
<a href="ViewEmployee.aspx">View Employee</a>
</nav>
</div>
<!-- Main Content -->
<asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>
<!-- Footer -->
<div class="footer">
<p>© 2025 Employee Management System</p>
</div>
</form>
</body>
</html>
Step 3: Create the Home Page
Add → Web Form using Master Page → Name: Default.aspx → Select Site1.Master
<%@ Page Title="Home" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="employee.Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Welcome to the Home Page</h2>
<p>Use the menu above to navigate through the Employee Management System.</p>
</asp:Content>
Step 4: Create Add Employee Page
Add → Web Form using Master Page → Name: AddEmployee.aspx → Select Site1.Master
AddEmployee.aspx
<%@ Page Title="Add Employee" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="AddEmployee.aspx.cs" Inherits="employee.AddEmployee" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Add Employee</h2>
<asp:TextBox ID="empName" runat="server"></asp:TextBox><br /><br />
<asp:TextBox ID="position" runat="server"></asp:TextBox><br /><br />
<asp:TextBox ID="sal" runat="server"></asp:TextBox><br /><br />
<asp:Button ID="btn" runat="server" Text="Add Employee" OnClick="btn_AddClick" /><br /><br />
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</asp:Content>
AddEmployee.aspx.cs
using System;
using System.Collections.Generic;
namespace employee
{
public partial class AddEmployee : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
empName.Attributes["placeholder"] = "Enter employee name";
position.Attributes["placeholder"] = "Enter employee position";
sal.Attributes["placeholder"] = "Enter employee salary";
}
}
protected void btn_AddClick(object sender, EventArgs e)
{
string name = empName.Text;
string pos = position.Text;
string salary = sal.Text;
List<Employee> employees = Session["Employees"] as List<Employee> ?? new List<Employee>();
employees.Add(new Employee { Name = name, Position = pos, Salary = salary });
Session["Employees"] = employees;
lblMessage.Text = "Employee added successfully!";
empName.Text = position.Text = sal.Text = "";
}
}
[Serializable]
public class Employee
{
public string Name { get; set; }
public string Position { get; set; }
public string Salary { get; set; }
}
}
Step 5: Create View Employee Page
Add → Web Form using Master Page → Name: ViewEmployee.aspx → Select Site1.Master
ViewEmployee.aspx
<%@ Page Title="View Employees" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="ViewEmployee.aspx.cs" Inherits="employee.ViewEmployee" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>All Employees</h2>
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="true"></asp:GridView>
</asp:Content>
ViewEmployee.aspx.cs
using System;
using System.Collections.Generic;
namespace employee
{
public partial class ViewEmployee : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<Employee> employees = Session["Employees"] as List<Employee> ?? new List<Employee>();
gv.DataSource = employees;
gv.DataBind();
}
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter