ASP.
NET Web Application - Exposure without Database
Aim
To create a simple ASP.NET Web Application using C# programming and built-in controls
(like TextBox, DropDownList, Button, and Label) without connecting to a database.
Procedure
1. Open Visual Studio and create a new ASP.NET Web Application project.
2. Add a new Web Form (Default.aspx).
3. Design the UI using ASP.NET controls (TextBox, DropDownList, Button, Label).
4. Write C# code in code-behind (Default.aspx.cs) to handle events.
5. Run the application and test input/output in the browser.
Code Implementation
1. Default.aspx (Design Page)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebAppExposure._Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Exposure to ASP.NET Web Applications and Tools</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align:center; margin-top:50px;">
<h2>ASP.NET Web Application (No Database)</h2>
<!-- TextBox for Name -->
<asp:Label ID="Label1" runat="server" Text="Enter Your Name:"></asp:Label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<br /><br />
<!-- DropDownList for Course Selection -->
<asp:Label ID="Label2" runat="server" Text="Select Course:"></asp:Label>
<asp:DropDownList ID="ddlCourse" runat="server">
<asp:ListItem Text="--Select--" Value="0"></asp:ListItem>
<asp:ListItem Text="C#" Value="C#"></asp:ListItem>
<asp:ListItem Text="ASP.NET" Value="ASP.NET"></asp:ListItem>
<asp:ListItem Text="SQL Server" Value="SQL Server"></asp:ListItem>
</asp:DropDownList>
<br /><br />
<!-- Button to Submit -->
<asp:Button ID="btnSubmit" runat="server" Text="Show Details"
OnClick="btnSubmit_Click" />
<br /><br />
<!-- Label for Output -->
<asp:Label ID="lblOutput" runat="server" ForeColor="Blue"
Font-Bold="True"></asp:Label>
</div>
</form>
</body>
</html>
2. Default.aspx.cs (Code Behind in C#)
using System;
namespace WebAppExposure
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Page load logic (if needed)
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string name = txtName.Text;
string course = ddlCourse.SelectedValue;
if (string.IsNullOrEmpty(name) || course == "0")
{
lblOutput.Text = "⚠ Please enter your name and select a course.";
lblOutput.ForeColor = System.Drawing.Color.Red;
}
else
{
lblOutput.Text = $"Hello {name}, you have selected the course: {course}.";
lblOutput.ForeColor = System.Drawing.Color.Green;
}
}
}
}
Expected Output
1. A web page opens with a TextBox, DropDownList, and a Button.
2. User enters their name and selects a course.
3. On clicking the button, a personalized message appears like:
Hello Priya, you have selected the course: ASP.NET.
4. If no input is given, it shows a warning message.
Result
Thus, a Web Application in ASP.NET using C# programming was created to demonstrate the
use of Web Controls and Event Handling without using any database connection.