FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
Experiment 4 & 5
AIM: Create web application using ASP.Net Web Controls and Rich Controls.
Source: WebForm1.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApp4_5.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
.auto-style-horizontal {
display: flex;
flex-direction: row; /* Aligns the items horizontally */
gap: 10px; /* Optional: Adds space between items */
.auto-style3 {
width: 365px;
padding: 20px;
background-color: lightblue;
.auto-style4{
display: flex;
flex-direction: row;
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |15
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
height: 58px;
.auto-style9 {
margin-left: 0px;
</style>
</head>
<body>
<form id="form1" runat="server">
<h1>Welcome to my web app with ASP.</h1>
<br />
<table class="auto-style1">
<tr>
<td class="auto-style5">
<b><asp:Label ID="Label1" runat="server" Text="Enter your first
name"></asp:Label></b>
</td>
<td class="auto-style6">
<asp:TextBox ID="TextBox1" runat="server" CssClass="auto-style9"
Width="396px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style7">
<b><asp:Label ID="Label2" runat="server" Text="Enter your last
name"></asp:Label></b>
</td>
<td class="auto-style8">
<asp:TextBox ID="TextBox2" runat="server" CssClass="auto-style9"
Width="396px"></asp:TextBox>
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |16
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
</td>
</tr>
<tr>
<td colspan="2" align="center"><b>Choose your Gender</b></td>
</tr>
<tr>
<td class="auto-style4" colspan="2" >
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
class="rowGroup" Width="197px">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td
</tr>
<tr>
<td colspan="2" align="center"><b>Your course choices</b></td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
CssClass="auto-style-horizontal" Width="339px">
<asp:ListItem>Computer</asp:ListItem>
<asp:ListItem>Management</asp:ListItem>
<asp:ListItem>PHARMACY</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td colspan="2" align="center"><b>Choose your country</b></td>
</tr>
<tr>
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |17
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
<td>
<asp:DropDownList ID="DropDownList1" runat="server" Width="220px">
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>China</asp:ListItem>
<asp:ListItem>USA</asp:ListItem>
<asp:ListItem>France</asp:ListItem>
<asp:ListItem>Canada</asp:ListItem>
<asp:ListItem>Burundi</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="ButtonSubmit" runat="server" Text="Submit the
Form" OnClick="Submit_Form" />
</td>
</tr>
<tr>
<td colspan="2" class="auto-style3">
<asp:Label ID="Label3" runat="server" Text="Your data will be
displayed here"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
Code Behind : WebForm1.aspx.cs
namespace WebApp4_5
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |18
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Submit_Form(object sender, EventArgs e)
{
string selectedValue = " ";
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
selectedValue += item.Value + " ";
}
}
Label3.Text = "<b>Your Full name is </b>" + TextBox1.Text + " " + TextBox2.Text +
"</br>" +
"<b>Your Gender is</b>: " + RadioButtonList1.SelectedValue + "</br><b>Selected
Courses </b>: "+ selectedValue
+ "</br><b>Your Country is: </b>" +DropDownList1.SelectedItem.Value;
}
Output:
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |19
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
Source: default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="prac_5.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Rich
Controls
<br />
<br />
Calendar
</div>
<asp:Calendar ID="Calendar1" runat="server"
OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar>
<br />
Upload a File
<br />
<br />
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |20
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
Ad Rotator
<br />
<br />
<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="Ads.xml"
CssClass="ad-rotator" Height="250px" width="900px"/>
<br />
<br />
MultiView Control
<br />
<br />
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<div>
The morning sun filtered through the thick canopy of trees, casting
dappled shadows on the forest floor. Birds chirped harmoniously, creating a serene melody
that blended with the soft rustle of leaves in the gentle breeze. As the path meandered
through the woods, the scent of pine and damp earth filled the air, evoking a sense of
tranquility. Every step on the moss-covered trail was cushioned, as if the forest itself
welcomed each visitor with open arms. It was a place where time seemed to slow down,
allowing one to truly connect with the rhythm of nature.
</div>
</asp:View>
<asp:View ID="View2" runat="server">
<div>
<div class="flex-shrink-0 flex flex-col relative items-end">
<div>
<div class="pt-0">
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |21
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
<div class="gizmo-bot-avatar flex h-8 w-8 items-center
justify-center overflow-hidden rounded-full">
<div class="relative p-1 rounded-sm flex items-center
justify-center bg-token-main-surface-primary text-token-text-primary h-8 w-8">
<svg class="icon-md" fill="none" height="41"
role="img" viewbox="0 0 41 41" width="41" xmlns="http://www.w3.org/2000/svg">
<!-- SVG content here -->
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="markdown prose w-full break-words dark:prose-invert dark">
<hr />
<p>The morning sun filtered through the thick canopy of
trees...</p>
<hr />
<p>In the bustling city, life moved at a frenetic pace...</p>
</div>
</div>
</asp:View>
<asp:View ID="View3" runat="server">
<div class="flex-shrink-0 flex flex-col relative items-end">
<div>
<div class="pt-0">
<div class="gizmo-bot-avatar flex h-8 w-8 items-center
justify-center overflow-hidden rounded-full">
<div class="relative p-1 rounded-sm flex items-center
justify-center bg-token-main-surface-primary text-token-text-primary h-8 w-8">
<!-- Content here -->
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |22
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
</div>
</div>
</div>
</div>
</div>
<div class="group/conversation-turn relative flex w-full min-w-0 flex-col
agent-turn">
<div class="flex-col gap-1 md:gap-3">
<div class="flex max-w-full flex-col flex-grow">
<div class="min-h-[20px] text-message flex w-full flex-col
items-end gap-2 whitespace-pre-wrap break-words">
<div class="markdown prose w-full break-words dark:prose-
invert dark">
<hr />
<p>The morning sun filtered through the thick canopy
of trees...</p>
<hr />
<p>In the bustling city, life moved at a frenetic
pace...</p>
<hr />
<p>The old library was a sanctuary for those who
sought solace...</p>
</div>
</div>
</div>
</div>
</div>
</asp:View>
</asp:MultiView>
</form>
<p> </p>
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |23
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
<p> </p>
</body>
</html>
Source: default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac_5
public partial class Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
MultiView1.ActiveViewIndex = 1;
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
} }
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |24
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
Source: default.aspx.cs
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<style>
.ad-rotator img {
width: 30px; /* Set your desired width */
height: 20px; /* Set your desired height */
</style>
<Ad>
<ImageUrl>~/Images/ad1.jpg</ImageUrl>
<NavigateUrl>http://www.example1.com</NavigateUrl>
<AlternateText>Ad 1</AlternateText>
<Impressions>50</Impressions>
</Ad>
<Ad>
<ImageUrl>~/Images/Ad2.jpeg</ImageUrl>
<NavigateUrl>http://www.example2.com</NavigateUrl>
<AlternateText>Ad 2</AlternateText>
<Impressions>50</Impressions>
</Ad>
<Ad>
<ImageUrl>~/Images/ad3.jpeg</ImageUrl>
<NavigateUrl>http://www.example3.com</NavigateUrl>
<AlternateText>Ad 3</AlternateText>
<Impressions>50</Impressions>
</Ad>
<Ad>
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |25
FACULTY OF ENGINEERING AND TECHNOLOGY
Department of Computer Engineering
01CE0523 - .NET Technologies
<ImageUrl>~/Images/a1.jpg</ImageUrl>
<NavigateUrl>http://www.example1.com</NavigateUrl>
<AlternateText>Ad 1</AlternateText>
<Impressions>50</Impressions>
</Ad>
<Ad>
<ImageUrl>~/Images/a2.jpg</ImageUrl>
<NavigateUrl>http://www.example1.com</NavigateUrl>
<AlternateText>Ad 1</AlternateText>
<Impressions>50</Impressions>
</Ad>
<Ad>
<ImageUrl>~/Images/a3.jpg</ImageUrl>
<NavigateUrl>http://www.example1.com</NavigateUrl>
<AlternateText>Ad 1</AlternateText>
<Impressions>50</Impressions>
</Ad>
</Advertisements>
Output:
GUY BRUNO NDIKUMANA (92200103297) BATCH: C |26