AWP (Own)
AWP (Own)
Practical 1a
Q. Program to demonstrate addition, subtraction, multiplication and division
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication3
{
public partial class _1c : System.Web.UI.Page
{
private int v1, v2;
private int res;
private double val1, val2, result;
Practical 1b
Q. Application to print Floyd’s Triangle
Code:
using System;
class Tri
{
static void printFloydTriangle(int n)
{
int i, j, val = 1;
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write(val + " ");
val++;
}
Console.WriteLine();
}
}
Practical 1c
Q. Create simple application to perform the following operations.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac1c
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Output:
Practical 2a
Q. Application to demonstrate Boxing and Unboxing
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace prac2a_1_
{
class Program
{
static void Main(string[] args)
{
int i = 100;
object iobj = i; //Boxing
i = 200; //changing value
int num = (int)iobj; //unboxing
Console.WriteLine($"Boxing :{iobj}");
Console.WriteLine($"Unboxing : {num}");
Console.WriteLine("Dev bhatt 103");
Console.ReadKey();
}
}
}
Output:
Practical 2b
Q. Application to perform addition and subtraction using delegate
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace prac2b
{
public delegate void addision(int a, int b);
public delegate void subtraction(int a, int b);
class sdelegates
{
public void Sum(int a, int b)
{
Console.WriteLine($"{a} + {b} = {a + b}");
}
public void sub(int a, int b)
{
Console.WriteLine($"{a} - {b} = {a - b}");
}
}
class Program
{
static void Main(string[] args)
{
sdelegates s = new sdelegates();
addision a = new addision(s.Sum);
subtraction b = new subtraction(s.sub);
a(1000,200);
b(1000, 200);
Console.WriteLine("dev bhatt 103");
Console.ReadLine();
}
}
}
Output:
Practical 2c
Q. Program to demonstrate multiple inheritance using interfaces.
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace prac2c
{
class Program
{
interface iface1
{
void languages();
}
class a : iface1
{
public void languages()
{
ArrayList MYlist = new ArrayList();
MYlist.Add("c");
MYlist.Add("python");
MYlist.Add("java");
MYlist.Add("c#");
Console.WriteLine("Languages leared by dev : ");
foreach (var elements in MYlist)
{
Console.WriteLine(elements);
}
Console.WriteLine("");
}
}
interface iface2
{
void courses();
}
class b : iface2
{
public void courses()
{
ArrayList MYlist = new ArrayList();
MYlist.Add("System desing");
MYlist.Add("operating system");
MYlist.Add("Computer networking");
MYlist.Add("c++");
Console.WriteLine("Languages provided by the university: ");
foreach (var elements in MYlist)
{
Console.WriteLine(elements);
}
}
}
Output:
Practical 3a
Q. Simple web page with various server controls
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac3a_1_
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Output:
Practical 3b
Q. Demonstrate the use of calendar controls to perform following operations.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac3b
if ((e.Day.Date >= new DateTime(2024, 9, 10)) && (e.Day.Date <= new DateTime(2024, 9,
20)))
e.Cell.BackColor = System.Drawing.Color.LightGreen;
Output:
Practical 3c
Q. Demonstrate the use of treeview operations on the web form
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac3c
Output :
Practical 4a
Q. Perform Validation in web pages
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
<p>
</body>
</html>
Output:
Practical 4b
Q. Web form to demonstrate use of Adrotator control
Code:
<?xml version="1.0" encoding="utf-8"?>
<Advertisements>
<Ad>
<ImageUrl>https://www.droidgamers.com/wp-content/uploads/2017/04/runescape-
1.jpg</ImageUrl>
<NavigateUrl>https://play.runescape.com/</NavigateUrl>
<AlternateText>Runescape</AlternateText>
<Impressions>1</Impressions>
<Keyword>Computer</Keyword>
</Ad>
</Advertisements>
Output:
https://play.runescape.com/runescape
Practical No : 4 (C)
Question : Create Web Form to demonstrate use User Controls.
Add -> New Item -> Web User Control
<div>
<asp:Label ID="lblMessage" runat="server" Text="Hello, World!"></asp:Label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</div>
Design :
WebUserControl1ascx.cs (Code) :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac4c
{
public partial class WebUserControl1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc:MyUserControl ID="myUserControl" runat="server" />
</div>
</form>
</body>
</html>
Output :
PRACTICAL NO:5(A)
QUESTION: Write a code to Create Web Form to demonstrate use of
Website Navigation controls.
CODE:
Create five web forms for :[Default ,Contacts, About, Team and History]
For creating Web.sitemap by following steps:
Right click on Project Name [WEB_NAVIGATION_PRACTICAL5(A)] -> then
select Add -> in the Dropdown list select New Item -> in that select Site Map
(Visual C#)
Then Web.config is needed ,which is already there in the project.
CONTACT.ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Contact.aspx.cs"
Inherits="prac5a.WebForm3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" Font-Size="0.8em"
PathSeparator=" : ">
<CurrentNodeStyle ForeColor="#333333" />
<NodeStyle Font-Bold="True" ForeColor="#990000" />
<PathSeparatorStyle Font-Bold="True" ForeColor="#990000" />
<RootNodeStyle Font-Bold="True" ForeColor="#FF8000" />
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="font-size: medium">
<asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" Font-Size="0.8em"
PathSeparator=" : ">
<CurrentNodeStyle ForeColor="#333333" />
<NodeStyle Font-Bold="True" ForeColor="#990000" />
<PathSeparatorStyle Font-Bold="True" ForeColor="#990000" />
<RootNodeStyle Font-Bold="True" ForeColor="#FF8000" />
</asp:SiteMapPath>
<br/>
<br />
<br />
<asp:Label ID="Label1" runat="server" Font-Size="XX-Large" Text="This is About Us
page"></asp:Label>
<br />
<br />
dev bhatt 103</div>
</form>
</body>
</html>
TEAM.ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Team.aspx.cs" Inherits="prac5a.WebForm4"
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" Font-Size="0.8em"
PathSeparator=" : ">
<CurrentNodeStyle ForeColor="#333333" />
<NodeStyle Font-Bold="True" ForeColor="#990000" />
WEB.CONFIG :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<siteMap defaultProvider="XmlSiteMapProvider">
<providers>
</providers>
</siteMap>
</system.web>
</configuration>
WEB.SITEMAP :
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
</siteMapNode>
</siteMapNode>
</siteMap>
Home :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="prac5a.WebForm1"
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<div>
</asp:Menu>
<br />
</div>
<p>
<br />
<br />
</form>
</body>
</html>
HISTORY:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="History.aspx.cs"
Inherits="prac5a.WebForm5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</asp:SiteMapPath>
</div>
<p>
</p>
</p>
<p>
</form>
</body>
</html>
OUTPUT :
After adding and naming master page write the below code in Source .
CODE:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs"
Inherits="SAMICS12 " %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>My Web Application</title>
<link href="Content/Site.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<header>
CODE :
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="SAMICS126 " %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Welcome to the Home Page!</h2>
<p>Badminton: A Sport of Strategy, Speed, and Skill!
Badminton is more than just a game; it’s a dynamic blend of agility, precision, and tactical depth.
Whether you’re a beginner or a seasoned player, badminton challenges your reflexes, pushes your
endurance, and sharpens your mind. </p>
</asp:Content>
DESIGN:
CODE :
%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="About.aspx.cs" Inherits="SAMICS126_PRAC5_B_.About" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>About Us</h2>
<p>Badminton: A Sport of Strategy, Speed, and Skill is dedicated to showcasing the beauty and
complexity of one of the fastest racket sports in the world.</p>
<p>Our mission is to inspire and educate players of all levels, from beginners to seasoned
professionals,strategic thinking, and physical prowess required to excel in badminton.</p>
</asp:Content>
DESIGN :
Contacts.aspx:
CODE :
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Contacts.aspx.cs" Inherits="SAMICS126_PRAC5_B_.Contacts" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Contact Us</h2>
<p>Get in Touch with Us
We’d love to hear from you! Whether you have questions, suggestions, or feedback, feel free to reach out to
us.
At Badminton: A Sport of Strategy, Speed, and Skill, we are committed to helping badminton enthusiasts
enhance
their game and explore everything this amazing sport has to offer.</p>
</asp:Content>
NOTE : At last, right click on Default.aspx and select set as start page.
OUTPUT:
Practical No : 6 (A)
Question : Create a web application for inserting and deleting records from a database.
Step 1 : Create a Web Application in Visual Studio 2019 and select ASP.NET Web Application (.NET
Framework). Then, Click Next.
1. Configure your project : Name your project [e.g., Prac6a]. And Choose a location to save it. Select
.NET Framework 4.7.2 (or a similar version). Then, Click Create.
2. Select the type of project : In the next window, choose Web Forms. Then ,Click Create.
Step 2 : Go to View and click on it , select SQL Server Object Explorer from the list .
Now , write the Attributes [i.e FirstName etc] and give them datatypes .
And Change the name of table below , change it from TABLE to Customer
Once done , click on Update button on top left corner and the following window appears , then Click
on Update Database
Now , you will able to see dbo.Customer database table created as shown below . Now right click and
select View Data and insert the data.
Here, You can see Data has been inserted and now Save it by pressing Ctrl + S.
Now Go to the Views option in Taskbar Select > Server Explorer Window
Then the following Window will open : Give the Server name same as in Step 2 and Select the
Database name. For e.g , here my database name is CustomerDB
Now , go to Solution explorer and Add -> WebForm and name it , [Customer] is the name given by
me.
Then, design as follows : From Toolbox Select DetailView and drag and drop in design page. Select
New data Source
Clicking on Advanced the following window appears , select both and click OK
In this window , click on TEST QUERY and the database table appears and then click on Finish
Here , you can see as we connected to database the attributes have appeared in design :
Here , Select Enable Inserting & Enable Deleting. Now your Program is all set to run , so press Ctrl +
F5
Output :
Practical No : 6 (B)
Question : Create a web application to display Using Disconnected Data Access and
Databinding using GridView.
Overview:
Disconnected Data Access: Using SqlDataAdapter and DataSet in ADO.NET for retrieving and
working with data without maintaining a constant connection to the database.
GridView: A control to display and manipulate tabular data.
{NOTE : REFER THE STARTING PHASE STEPS SAME AS PRACTICAL 6(A) OF HOW TO
CREATE A DATABASE AND RUN QUERIES}
We will automatically get this query written as we can see in the below picture :
CREATE TABLE [dbo].[Users]
(
[Id] INT PRIMARY KEY IDENTITY(1,1),
[Name] NVARCHAR(50) ,
[Email] NVARCHAR(50)
)
Click on Update and then the following window will appear select Update Database.
After this we Right click on Users database created and select View Data.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>User List</title>
</head>
Design :
try
{
connection.Open(); // Ensure the connection is open
dataAdapter.Fill(dataSet);
Grid.DataSource = dataSet.Tables[0];
Grid.DataBind();
}
catch (SqlException ex)
{
// Handle the error appropriately (e.g., logging or displaying an error message)
Response.Write("An error occurred: " + ex.Message);
}
finally
{
connection.Close(); // Ensure the connection is closed
}
}
}
}
Output :
Practical No : 7 (A)
Questions : Create a web application to demonstrate the use of different types of
Cookies.
WEB FORM AXPX.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MEET__129
{
public partial class MEET_129 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Creating HttpCookie instance by name "creator"
HttpCookie creatorCookie = new HttpCookie("creator");
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MEET 129.aspx.cs"
Inherits="MEET__129.MEET_129" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Cookie Demonstration</title>
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<h1>Cookie Demonstration</h1>