ASP.NET Practical Tasks Overview
ASP.NET Practical Tasks Overview
DEPARTMENT OF
COMPUTER SCIENCE
SEMESTER V - PRACTICALS
I I I - I N T E G R A T E D M . S C . D A T A S C I E N C E & B I G D A T A A N A LY T I C S
2025 - 2026
Name
Register Number
Subject Code
THIRUVALLUVAR UNIVERSITY
(A State University Accredited with “B+” by NAAC)
Serkaddu, Vellore - 632 511
SEMESTER V - PRACTICALS
AUTHENTICATION –
13 12-9-2025 56
AUTHORIZATION
AIM:
DESCRIPTION :
This program is a basic [Link] Web Forms application that demonstrates how to collect user
input, process it on the server side, and display dynamic output on the web page.
🔹 Components Used
2. Button (btnSubmit) – Submits the input and triggers an event on the server.
1. When the page loads, it shows a textbox, a button, and an empty label.
3. On clicking the "Say Hello" button, the event handler btnSubmit_Click in the code-behind file
([Link]) executes.
5. The message is shown on the same page without reloading it from scratch, thanks to [Link]’s
server-side event handling.
1
PROGRAM:
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>[Link] Hello Program</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Enter Your Name</h2>
<asp:TextBox ID="txtName" runat="server" />
<asp:Button ID="btnSubmit" runat="server" Text="Say Hello"
OnClick="btnSubmit_Click" />
<br /><br />
<asp:Label ID="lblMessage" runat="server" ForeColor="Blue"
Font-Size="Large"></asp:Label>
</div>
</form>
</body>
</html>
[Link]
using System;
namespace ex1
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
2
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string name = [Link]();
if ()
{
[Link] = "Hello, " + name + "!";
}
else
{
[Link] = "Please enter your name.";
}
}
}
}
3
OUTPUT:
RESULT:
Thus, the above Web Application and Tools [Link] program executed successfully.
4
[Link]
HTML CONTROLS
DATE:02-07-2025
AIM:
DESCRIPTION:
This [Link] Web Forms application demonstrates the use of HTML Server Controls (TextBox,
RadioButton, Button, and Label) to capture and display user input dynamically.
o Two RadioButton controls (rdoMale and rdoFemale) grouped under the same
GroupName to select gender.
In the code-behind file ([Link]), the btnSubmit_Click event handler retrieves the
values entered by the user:
After submission, the program dynamically generates a formatted message and displays it
in the lblOutput label.
5
PROGRAM:
[Link]
Gender
<asp:RadioButton ID="rdoMale" runat="server" Text="Male" GroupName="myop"/>
<asp:RadioButton ID="rdoFemale" runat="server" Text="FeMale"
GroupName="myop"/>
<br /><br />
<hr />
<h3>Output:</h3>
<asp:Label ID="lblOutput" runat="server" ></asp:Label>
</form>
</body>
</html>
[Link]
using System;
namespace WebApplication2
6
{
public partial class _Default : [Link]
{
protected void Page_Load(object sender, EventArgs e) { }
public void btnSubmit_Click(object sender, EventArgs e)
{
string name = [Link];
string email = [Link];
string gender = [Link] ? "Male" : ([Link] ? "Female" : "Not
Selected");
7
OUTPUT:
RESULT:
Thus, the above [Link] program using HTML Controls executed successfully.
8
[Link]
SERVER CONTROLS
DATE:10-07-2025
AIM:
To write a [Link] program to create Web Applications which contains Server Controls.
DESCRIPTION :
This [Link] Web Forms application is designed to check whether a person is eligible
to vote based on their age. It uses server controls for input and output, along with C# code-
behind logic for processing.
If the input is invalid (not numeric), it prompts the user to enter a valid age.
9
PROGRAM:
[Link]
<h3>Result:</h3>
<asp:Label ID="lblResult" runat="server" Text=""></asp:Label>
</form>
</body>
</html>
[Link]
using System;
namespace WebApplication3
{
public partial class _Default : Page
{
10
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnCheck_Click(object sender, EventArgs e)
{
string name = [Link];
int age;
11
OUTPUT:
RESULT:
Thus, the above Server Controls [Link] program executed successfully.
12
[Link]
WEB CONTROLS
DATE:18-07-2025
AIM:
DESCRIPTION:
This [Link] Web Forms application checks whether a given number is prime or not
using web controls and C# code-behind.
Working of the Program:
1. The webpage ([Link]) provides:
o A TextBox (txtNumber) for entering an integer.
o A Button (btnCheck) to trigger the prime number check.
o A Label (lblResult) to display the result dynamically.
2. When the user clicks the Check Prime button, the event handler btnCheck_Click in
[Link] is executed.
3. The logic works as follows:
o The input is validated using [Link]() to ensure it is an integer.
o If the number is less than or equal to 1, it is immediately declared not prime.
o Otherwise, the program checks divisibility from 2 up to the square root of the
number ([Link](num)).
o If the number is divisible by any of these values, it is marked not prime; otherwise,
it is a prime number.
13
PROGRAM:
[Link]
<html>
<head runat="server">
<title>Prime Number Verification</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Prime Number Verification using Web Controls</h2>
[Link]
using System;
namespace ex4
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
14
{
}
protected void btnCheck_Click(object sender, EventArgs e)
{
int num;
if ([Link]([Link], out num))
{
if (num <= 1)
{
[Link] = num + " is NOT a prime number.";
return;
}
if (isPrime)
[Link] = num + " is a PRIME number.";
else
[Link] = num + " is NOT a prime number.";
}
else
{
[Link] = "Please enter a valid integer.";
}
}
}
}
15
OUTPUT:
RESULT:
Thus, the above [Link] program using Web Controls executed successfully.
16
[Link]
LIST CONTROLS
DATE:28-07-2025
AIM:
To write a [Link] program for creating Web application Using List Controls.
DESCRIPTION:
This [Link] Web Forms application demonstrates how to use the DropDownList control for
country selection with server-side event handling.
The AutoPostBack property is enabled, which means that when the user changes the
selected item, the page posts back to the server automatically.
1. When the page first loads (Page_Load), if it is not a postback, the label displays the
instruction:
“Please select your country.”
2. When the user selects a country from the DropDownList:
17
PROGRAM:
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>Country Selection using DropDownList</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Select Your Country</h2>
<asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged">
<asp:ListItem Text="-- Select Country --" Value="" />
<asp:ListItem Text="India" Value="India" />
<asp:ListItem Text="USA" Value="USA" />
<asp:ListItem Text="UK" Value="UK" />
<asp:ListItem Text="Australia" Value="Australia" />
<asp:ListItem Text="Canada" Value="Canada" />
</asp:DropDownList>
<br /><br />
<asp:Label ID="lblMessage" runat="server" Font-Bold="true"
ForeColor="Green"></asp:Label>
</div>
</form>
</body>
</html>
18
[Link]
using System;
namespace list
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
[Link] = "Please select your country.";
}
}
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
if ()
{
[Link] = "You selected: " + [Link];
}
else
{
[Link] = "Please select a valid country.";
}
}
}
}
19
OUTPUT:
RESULT:
Thus, the above Web Application using List Controls in [Link] executed successfully.
20
[Link]
RICH CONTROL - VALIDATION CONTROLS
DATE:05-08-2025
AIM:
To create an [Link] web page design using Rich Control, validate user input using Validation
controls. working with File concepts.
DESCRIPTION:
This [Link] Web Forms application demonstrates the use of Rich Controls, Validation
Controls, and basic File Handling concepts.
o The web page allows the user to enter their Name, Email ID, select Date of Birth
using a Calendar control, and upload a file using the FileUpload control.
2. Validation Controls
o A RequiredFieldValidator ensures that the Name and File fields are not left empty.
3. Rich Controls
o User details (Name, Email, DOB) are stored in a text file named [Link] on the
server.
o Each new submission appends user data to the file, preserving previous entries.
5. Output
21
PROGRAM:
[Link]
[Link]
using System;
namespace richcontrl
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if ([Link])
{
string name = [Link];
string email = [Link];
string dob = [Link]();
// Save uploaded file
if ([Link])
{
string savePath = [Link]("~/Uploads/");
if ()
{
[Link](savePath);
}
string filePath = savePath + [Link]([Link]);
23
[Link](filePath);
}
24
OUTPUT:
RESULT:
Thus, the above [Link] program using Rich Controls executed successfully.
25
[Link]
DATA CONTROLS
DATE:06-08-2025
AIM:
DESCRIPTION :
This [Link] Web Forms application demonstrates Data Controls (DropDownList and
GridView) for state selection in India.
When a state is selected, the corresponding capital city and official language are fetched
from a dictionary in the code-behind.
4. The details of the selected state (State, Capital, Language) are displayed in the GridView.
26
PROGRAM:
[Link]
</form>
</body>
</html>
27
[Link]
using System;
namespace StateSelection
{
public partial class _Default : [Link]
{
// Sample State Data
private Dictionary<string, (string Capital, string Language)> states = new
Dictionary<string, (string, string)>()
{
{"Tamil Nadu", ("Chennai", "Tamil")},
{"Kerala", ("Thiruvananthapuram", "Malayalam")},
{"Karnataka", ("Bengaluru", "Kannada")},
{"Maharashtra", ("Mumbai", "Marathi")},
{"West Bengal", ("Kolkata", "Bengali")}
};
if ([Link](selectedState))
{
var details = new List<dynamic>
{
new { State = selectedState, Capital = states[selectedState].Capital, Language =
states[selectedState].Language }
28
};
[Link] = details;
[Link]();
}
else
{
[Link] = null;
[Link]();
}
}
}
}
29
OUTPUT:
RESULT:
Thus, the above [Link] program using Data Controls executed successfully.
30
[Link]
DATA BINDING WITH WEB CONTROLS
DATE:13-08-2025
AIM:
DESCRIPTION:
This [Link] Web Forms application demonstrates the concept of Data Binding with Web
Controls using a DropDownList and a GridView.
When a user selects a country from the DropDownList, the SelectedIndexChanged event is
triggered, and the selected value is displayed in a Label control (lblMessage).
The program also demonstrates binding tabular data to a GridView control (GridView1). A
DataTable is created at runtime containing student details like Roll No, Name, and Course.
This DataTable is assigned as the data source to the GridView and displayed in a tabular
format.
The IsPostBack property ensures that the data binding occurs only during the first page load,
preventing the controls from being re-bound on every postback.
31
PROGRAM:
[Link]
Inherits="_Default" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>[Link] Data Binding Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Data Binding with Web Controls</h2>
<h3>Student Details</h3>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true"
BorderColor="Black" BorderWidth="1px" CellPadding="5">
</asp:GridView>
</div>
</form>
</body>
</html>
32
[Link]
using System;
if (!IsPostBack)
// Binding DropDownList
[Link] = countries;
[Link]();
[Link]("Roll No");
[Link]("Name");
[Link]("Course");
[Link] = dt;
[Link]();
33
}
34
OUTPUT:
RESULT:
Thus, the above [Link] program for Data Binding with Web controls executed successfully.
35
[Link]
DATA BINDING WITH DATA CONTROLS
DATE:22-08-2025
AIM:
DESCRIPTION:
This [Link] Web Forms application demonstrates the concept of data binding with data
controls through a College Course Selection system. The application allows students to select a
department and choose one or more courses offered under that department.
2. When the user selects a department, the ListBox control (lstCourses) is populated
dynamically with the courses available in that department using data binding.
3. The student can select multiple courses from the list and submit the selection.
4. The chosen department and corresponding courses are displayed in a GridView control
(gvSelectedCourses) for better tabular representation.
5. Data is managed internally using a Dictionary (key-value collection) and a DataTable for
storing and displaying selected values.
36
PROGRAM:
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>College Course Selection</title>
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<h2>College Course Selection</h2>
OnSelectedIndexChanged="ddlDepartment_SelectedIndexChanged"></asp:DropDownList
>
<br /><br />
[Link]
using System;
namespace datacontl
{
public partial class _Default : Page
{
Dictionary<string, List<string>> courseData = new Dictionary<string, List<string>>()
{
{ "Computer Science", new List<string>{ "AI", "DATA SCIENCE", "MACHINE LEARNING", "BIG
DATA" } },
{ "Commerce", new List<string>{ "General", "Finance", "Computer Application", "Corporate" }
},
};
}
protected void ddlDepartment_SelectedIndexChanged(object sender, EventArgs e)
{
string dept = [Link];
[Link] = courseData[dept];
[Link]();
}
38
foreach (var item in [Link]())
{
DataRow row = [Link]();
row["Department"] = dept;
row["Course"] = [Link][item].Text;
[Link](row);
}
[Link] = dt;
[Link]();
}
}
}
39
OUTPUT:
RESULT:
Thus, the above [Link] program for Data Binding with Data controls executed successfully.
40
[Link]
DATABASE OPERATIONS
DATE:25-08-2025
AIM:
To Create a [Link] program to perform Database Operations Insert, Update and Delete.
DESCRIPTION:
This [Link] Web Forms application demonstrates basic database operations (CRUD)—
Create, Read, Update, Delete—on a students table using standard [Link] controls
(TextBoxes, Labels, Buttons).
User Interface:
The page ([Link]) contains TextBox controls to input:
o Student ID, Name, Age, Course
Buttons to perform operations:
o Insert: Add a new student record.
o Update: Modify an existing student record by StudentID.
o Delete: Remove a student record by StudentID.
A Label (lblMessage) displays success or error messages to the user.
Backend Logic ([Link]):
Uses [Link] with SqlConnection and SqlCommand to interact with SQL Server.
Connection string includes:
o Encrypt=True and TrustServerCertificate=True to avoid SSL certificate issues.
o Integrated Security for Windows Authentication.
Insert Operation: Adds a new student with name, age, and course.
Update Operation: Updates existing student details based on StudentID. Shows a message
if the ID is not found.
Delete Operation: Deletes a student record by StudentID. Shows a message if the ID does
not exist.
Input Clearing: After every operation, all TextBox fields are cleared using a ClearFields()
method.
41
PROGRAM:
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>Basic CRUD without Data Controls</title>
</head>
<body>
<form id="form1" runat="server">
<div style="font-family:Arial; padding:20px;">
<h2>Student Management (Basic Controls)</h2>
[Link]
using System;
using [Link];
namespace StudentBasic
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
[Link] = "";
}
string conStr = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=forum;Integrated
Security=True;Encrypt=True;TrustServerCertificate=True;";
// Insert new student
protected void btnInsert_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(conStr))
{
string query = "INSERT INTO students (Name, Age, Course) VALUES (@Name, @Age,
@Course)";
SqlCommand cmd = new SqlCommand(query, con);
[Link]("@Name", [Link]);
[Link]("@Age", Convert.ToInt32([Link]));
[Link]("@Course", [Link]);
[Link]();
[Link]();
[Link]();
[Link] = "Record inserted successfully!";
}
ClearFields();
}
43
string query = "UPDATE students SET Name=@Name, Age=@Age, Course=@Course
WHERE StudentID=@ID";
SqlCommand cmd = new SqlCommand(query, con);
[Link]("@ID", Convert.ToInt32([Link]));
[Link]("@Name", [Link]);
[Link]("@Age", Convert.ToInt32([Link]));
[Link]("@Course", [Link]);
[Link]();
int rows = [Link]();
[Link]();
if (rows > 0)
[Link] = "Record updated successfully!";
else
[Link] = "Student ID not found!";
}
ClearFields();
}
// Delete student
protected void btnDelete_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(conStr))
{
string query = "DELETE FROM students WHERE StudentID=@ID";
SqlCommand cmd = new SqlCommand(query, con);
[Link]("@ID", Convert.ToInt32([Link]));
[Link]();
int rows = [Link]();
[Link]();
if (rows > 0)
[Link] = "Record deleted successfully!";
else
[Link] = "Student ID not found!";
}
ClearFields();
}
44
OUTPUT:
RESULT:
Thus, the above [Link] program for Database Manipulation executed successfully.
45
[Link]
DATABASE OPERATIONS USING DATA
CONTROLS
DATE:02-09-2025
AIM:
DESCRIPTION:
To create a simple web application for managing employee records (Name and Salary) using
[Link] GridView and data controls, supporting CRUD operations (Create, Read, Update,
Delete) with database interaction.
Add Employee – Users can enter the employee's name and salary and insert it into the
database using the Insert Employee button.
Display Employees – The GridView control displays all records from the Employees
table with proper formatting for currency.
Edit Employee – Inline editing is supported in the GridView. Users can modify name
and salary, then update the database.
Delete Employee – Users can delete an employee record directly from the GridView.
Paging – GridView supports paging with 5 records per page for better navigation.
Database Details:
Database Name: forum
Table: Employees
Columns:
o EmployeeID (Primary Key, int, identity)
o Name (nvarchar)
o Salary (decimal)
46
PROGRAM:
[Link]
<Columns>
<asp:BoundField DataField="EmployeeID" HeaderText="ID"
ReadOnly="true" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Salary" HeaderText="Salary"
DataFormatString="{0:C}" />
47
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
[Link]
using System;
using [Link];
using [Link];
namespace Employee
{
public partial class _Default : Page
{
string conStr = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=forum;Integrated
Security=True;Encrypt=True;TrustServerCertificate=True;";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindGrid();
}
private void BindGrid()
{
using (SqlConnection con = new SqlConnection(conStr))
{
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Employees", con);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
}
}
protected void btnInsert_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(conStr))
{
string query = "INSERT INTO Employees (Name, Salary) VALUES (@Name, @Salary)";
SqlCommand cmd = new SqlCommand(query, con);
[Link]("@Name", [Link]);
[Link]("@Salary", [Link]([Link]));
48
[Link]();
[Link]();
[Link]();
}
// Edit
protected void GridView1_RowEditing(object sender,
[Link] e)
{
[Link] = [Link];
BindGrid();
}
// Cancel Edit
protected void GridView1_RowCancelingEdit(object sender,
[Link] e)
{
[Link] = -1;
BindGrid();
}
// Update
protected void GridView1_RowUpdating(object sender,
[Link] e)
{
int id = Convert.ToInt32([Link][[Link]].Value);
string name =
(([Link])[Link][[Link]].Cells[1].Controls[0]).Text;
string salary =
(([Link])[Link][[Link]].Cells[2].Controls[0]).Text;
49
[Link]();
[Link]();
[Link]();
}
[Link] = -1;
BindGrid();
}
// Delete
protected void GridView1_RowDeleting(object sender,
[Link] e)
{
int id = Convert.ToInt32([Link][[Link]].Value);
BindGrid();
}
// Paging
protected void GridView1_PageIndexChanging(object sender,
[Link] e)
{
[Link] = [Link];
BindGrid();
}
}
}
50
OUTPUT:
RESULT:
Thus, the above [Link] program for Database Manipulation with Data Control executed
successfully.
51
[Link]
XML CLASSES
DATE:03-09-2025
AIM:
DESCRIPTION:
This [Link] Web Forms program demonstrates the use of XML classes in C# for creating and
reading XML files.
The program uses the XmlDocument class to work with XML data.
o With the XmlElement class, elements such as <Employees> and <Employee> are
created dynamically.
o The InnerXml property helps assign nested XML content to each <Employee>.
o Finally, the Save() method stores the XML structure in a physical file.
The Label control shows output messages like the file creation confirmation or the
employee details retrieved from the XML file.
52
PROGRAM:
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>Simple XML Demo</title>
</head>
<body>
<form id="form1" runat="server">
<h2>Simple XML Demo</h2>
[Link]
using System;
using [Link];
namespace XmlSimple
{
public partial class _Default : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
string xmlPath = @"C:\Users\tvmkr\OneDrive\Desktop\New folder\[Link]"; //
Change path as needed
53
protected void btnCreate_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
// Root element
XmlElement root = [Link]("Employees");
[Link](root);
// Employee 1
XmlElement emp1 = [Link]("Employee");
[Link] = "<ID>1</ID><Name>John</Name>";
[Link](emp1);
// Employee 2
XmlElement emp2 = [Link]("Employee");
[Link] = "<ID>2</ID><Name>Mary</Name>";
[Link](emp2);
[Link](xmlPath);
[Link] = "XML file created at: " + xmlPath;
}
[Link] = output;
}
}
}
54
OUTPUT:
RESULT:
Thus, the above [Link] program for implementing XML Class executed successfully.
55
[Link]
AUTHENTICATION – AUTHORIZATION
DATE:12-09-2025
AIM:
DESCRIPTION:
This [Link] Web Forms application demonstrates basic authentication and authorization using login
credentials and session management.
o When the Login button is clicked, the application validates the entered username and
password.
o If the session is null (meaning the user has not logged in or has logged out), the user
is redirected back to the Login Page (authentication check).
o A Logout button allows the user to end the session. On logout, the session is
cleared, and the user is redirected to the Login Page.
56
PROGRAM:
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>Login Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="font-family:Arial; padding:20px;">
<h2>User Login</h2>
57
[Link]
using System;
namespace Login
{
public partial class _Default : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string username = [Link]();
string password = [Link]();
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>Welcome Page</title>
58
</head>
<body>
<form id="form1" runat="server">
<div style="font-family:Arial; padding:20px;">
<h2>Welcome Page</h2>
[Link]
namespace Login
{
public partial class Welcome : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Username"] == null)
{
// If not authenticated, redirect to login
[Link]("[Link]");
}
else
{
[Link] = "Hello, " + Session["Username"].ToString() + "! You are
logged in.";
}
}
protected void btnLogout_Click(object sender, EventArgs e)
{
// Clear session and redirect to login page
[Link]();
[Link]("[Link]");
}
}
}
59
OUTPUT:
RESULT:
Thus, the above [Link] program for Authentication - Authorization executed successfully.
60
[Link]
TICKET RESERVATION
DATE:19-09-2025
AIM:
DESCRIPTION:
This [Link] Web Forms application demonstrates a simple ticket reservation system using
web controls and server-side validation.
o Two DropDownList controls (ddlFrom and ddlTo) for selecting the source and
destination cities.
Reservation Process:
o When the user clicks the Reserve Ticket button, the program checks whether all
fields are filled properly and if the number of tickets is valid.
o Validation ensures that the source and destination cannot be the same and that the
ticket count is numeric.
Output Display:
o The Label (lblMessage) is used to display either error messages (e.g., missing
fields, invalid input) or the reservation confirmation message.
o After a successful booking, the input fields are cleared for new entries.
61
PROGRAM:
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ticket Reservation</title>
</head>
<body>
<form id="form1" runat="server">
<div style="font-family:Arial; padding:20px;">
<h2>Ticket Reservation</h2>
62
<asp:Label ID="lblTickets" runat="server" Text="Number of Tickets:
"></asp:Label>
<asp:TextBox ID="txtTickets" runat="server"></asp:TextBox>
<br /><br />
[Link]
using System;
namespace TicketReservation
{
public partial class _Default : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnReserve_Click(object sender, EventArgs e)
{
string name = [Link]();
string from = [Link];
string to = [Link];
int tickets = 0;
if (from == to)
{
63
[Link] = "Source and destination cannot be the same.";
return;
}
[Link] = $"Hello {name}, your reservation for {tickets} ticket(s) from {from} to {to}
is confirmed!";
64
OUTPUT:
RESULT:
Thus, the above [Link] program for Ticket Reservation executed successfully.
65
[Link]
ONLINE EXAMINATION
DATE:22-09-2025
AIM:
DESCRIPTION:
This [Link] Web Forms program demonstrates a simple Computer Science multiple-choice
online examination system using [Link] controls.
o When the user clicks the Submit Exam button, the program checks the selected
answers of each RadioButtonList.
o Finally, the total score is displayed on the web page in the result label.
66
PROGRAM:
[Link]
<!DOCTYPE html>
<html>
<head runat="server">
<title>Computer Science Online Exam</title>
</head>
<body>
<form id="form1" runat="server">
<div style="font-family:Arial; padding:20px;">
<h2>Computer Science Online Examination</h2>
[Link]
using System;
namespace CSExam
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
int score = 0;
// Check Q1
if ([Link] == "1")
score++;
// Check Q2
if ([Link] == "1")
score++;
// Check Q3
if ([Link] == "1")
score++;
RESULT:
Thus, the above [Link] program for Data Binding with Data controls executed successfully.
69