AWPpp
AWPpp
AWPpp
NAME: ________________
Class: TY Bsc.IT
1|Page
TyBsc-IT 2024-2025
INDEX
Sr.no Topic Date Sign
2|Page
TyBsc-IT 2024-2025
3|Page
TyBsc-IT 2024-2025
Practical No: 1A
Aim: Create an application to print on screen the output of adding,
subtracting, multiplying and dividing two numbers entered by the user.
Source Code:
Default.aspx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
4|Page
TyBsc-IT 2024-2025
</head>
<body>
a: <asp:TextBox ID="TextBox1"
b:
<asp:TextBox ID="TextBox2"
</div>
</form>
5|Page
TyBsc-IT 2024-2025
</body>
</html>
Default.aspx.cs
using System;
using
System.Collections.Gene
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
6|Page
TyBsc-IT 2024-2025
sender, EventArgs e)
addition = Convert.ToInt32(TextBox1.Text) +
Convert.ToInt32(TextBox2.Text);
subtraction = Convert.ToInt32(TextBox1.Text) -
Convert.ToInt32(TextBox2.Text);
multiplication = Convert.ToInt32(TextBox1.Text) *
Convert.ToInt32(TextBox2.Text); division =
Convert.ToInt32(TextBox1.Text) /
Convert.ToInt32(TextBox2.Text);
7|Page
TyBsc-IT 2024-2025
division;
Output
8|Page
TyBsc-IT 2024-2025
Practical No: 1B
Aim: Create an application to demonstrate following operations.
2)Prime Number.
Source Code:
1)Generate Fibonacci Series.
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
9|Page
TyBsc-IT 2024-2025
<div>
</div>
</form>
</body>
10 | P a g e
TyBsc-IT 2024-2025
</html>
Default.aspx.cs
using System;
using
System.Collections.Gene
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
11 | P a g e
TyBsc-IT 2024-2025
sender, EventArgs e)
int a, b, c,
i, n; a
= 0;
b = 1;
n=
Convert.ToInt32(TextBox1.Text); for
(i = 1; i <= n; i++)
c = a + b;
Label1.Text = Label1.Text
12 | P a g e
TyBsc-IT 2024-2025
c.ToString();
a = b; b
= c;
Output
13 | P a g e
TyBsc-IT 2024-2025
14 | P a g e
TyBsc-IT 2024-2025
2)Prime Number.
Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
</form>
15 | P a g e
TyBsc-IT 2024-2025
</body>
</html>
Default.aspx.cs
using System;
using
System.Collections.Gene
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
16 | P a g e
TyBsc-IT 2024-2025
sender, EventArgs e)
{ int n, i, s
= 0;
n=
Convert.ToInt32(TextBox1.
Text);
if (n == 0 || n == 1)
s = 1; for (i = 2; i
<= n / 2; i++)
if (n % i == 0)
17 | P a g e
TyBsc-IT 2024-2025
s = 1;
break;
if (s == 0)
Output
18 | P a g e
TyBsc-IT 2024-2025
19 | P a g e
TyBsc-IT 2024-2025
Practical No: 2
Aim: Create a simple web page with various server controls to
demonstrate setting and use of their properties.(Example :
AutoPostBack) Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
20 | P a g e
TyBsc-IT 2024-2025
Address:<asp:TextBox ID="TextBox4"
runat="server"></asp:TextBox><br /><br />
Subject:<br />
</div>
</form>
</body>
</html>
Default.aspx.cs
using System;
using
System.Collections.Gene
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
sender, EventArgs e)
true)
23 | P a g e
TyBsc-IT 2024-2025
Label1.Text += CheckBox2.Text +
true) Label1.Text +=
(CheckBox4.Checked == true)
/>"; if (CheckBox5.Checked ==
true)
EventArgs e)
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
CheckBox1.Checked = false;
24 | P a g e
TyBsc-IT 2024-2025
CheckBox4.Checked = false;
CheckBox5.Checked = false;
Label1.Text = "";
Output:
25 | P a g e
TyBsc-IT 2024-2025
26 | P a g e
TyBsc-IT 2024-2025
Pract 4 A)
Aim : Create a Registration form to demonstrate use of various
Validation Controls.
Source Code:
Deafult.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server"
27 | P a g e
TyBsc-IT 2024-2025
ErrorMessage="Field Required"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator><br /><br
/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ErrorMessage="Age is Required"
ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server"
ErrorMessage="Field Required"
ControlToValidate="TextBox3"></asp:RequiredFieldValidator><br /><br
/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server"
28 | P a g e
TyBsc-IT 2024-2025
ErrorMessage="Field Required"
ControlToValidate="TextBox4"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ErrorMessage="Email should have @" ControlToValidate="TextBox4"
ValidationExpression=".+@.+"></asp:RegularExpressionValidator><br
/><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server"
ErrorMessage="RequiredField"
ControlToValidate="TextBox5"></asp:RequiredFieldValidator><br /><br
/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6"
runat="server"
ErrorMessage="RequiredField"
ControlToValidate="TextBox6"></asp:RequiredFieldValidator><br />
29 | P a g e
TyBsc-IT 2024-2025
</div>
</form>
</body>
</html>
OUTPUT:
30 | P a g e
TyBsc-IT 2024-2025
31 | P a g e
TyBsc-IT 2024-2025
Practical No: 3B
Aim: Create Web Form to demonstrate use of Adrotator Control
Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</asp:ScriptManager>
</asp:Timer>
32 | P a g e
TyBsc-IT 2024-2025
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1"
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
XMLFile.xml
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>~/image/google.jpeg</ImageUrl>
33 | P a g e
TyBsc-IT 2024-2025
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>
</AlternateText>
</Ad>
<Ad>
<ImageUrl>~/image/facebook.jpeg</ImageUrl>
<NavigateUrl>http://www.facebook.com</NavigateUrl>
<AlternateText>
</AlternateText>
</Ad>
<Ad>
<ImageUrl>~/image/whatsapp.jpeg</ImageUrl>
<NavigateUrl>http://www.whatsapp.com</NavigateUrl>
<AlternateText>
34 | P a g e
TyBsc-IT 2024-2025
</AlternateText>
</Ad>
</Advertisements>
OUTPUT:
35 | P a g e
TyBsc-IT 2024-2025
36 | P a g e
TyBsc-IT 2024-2025
Practical No: 4A
Aim: Create a web application to demonstrate use of Master Page with
applying Style and themes for page beautification.
->Create a Master page
Source Code:
MasterPage.master
Home.aspx
<%@ Page Title="" Language="C#"
MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Home.aspx.cs" Inherits="Home" %>
</asp:Content>
<asp:Content ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2>Fort,Mumbai
400006</h2>
</asp:Content>
37 | P a g e
TyBsc-IT 2024-2025
->Create a Registration
Form Registration.aspx
<%@ Page Title="" Language="C#"
MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Registration.aspx.cs" Inherits="Registration" %>
</asp:Content>
<asp:Content ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1>Registration Form</h1>
</asp:Content>
</asp:Content>
<asp:Content ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
Username:<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox><br /><br />
Password:<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox><br />
</asp:Content>
39 | P a g e
TyBsc-IT 2024-2025
AboutUs.aspx
<%@ Page Title="" Language="C#"
MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="AboutUs.aspx.cs" Inherits="AboutUs" %>
</asp:Content>
<asp:Content ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h3>Introduction:</h3>
Our College was the first Commerce College started by the People's
Education Society and is the second oldest Commerce College in
Mumbai.
40 | P a g e
TyBsc-IT 2024-2025
The built-in area includes the College office the offices of the
Selffinanced Programmes, the library, 3 computer labs, the Examination
department,
the NCC, NSS and Gymkhana rooms, the Principal's cabin, Professors'
Common Room, 14 other class roooms and 1 small room for tutorials as
well as
the Ph.D. Research Centre. The library lends itself to a quiet and
reflective ambience for the students as well as the faculty members.
41 | P a g e
TyBsc-IT 2024-2025
</asp:Content>
StyleSheet.css body
backgroundcolor:Gray;
background-
image:url(clg.jpg) }
h1{ color:Yellow;
font-family:Arial;
font-size:medium;
text-align:center; }
h2{ color:Red;
42 | P a g e
TyBsc-IT 2024-2025
font-family:Arial;
font-size:medium; }
p{
color:Green;
} b{
color:Orange;
SkinFile.skin
<%--
43 | P a g e
TyBsc-IT 2024-2025
</asp:GridView>
--%>
44 | P a g e
TyBsc-IT 2024-2025
Output:
45 | P a g e
TyBsc-IT 2024-2025
Practical No: 4B
Aim : Create a web application to demonstrate various States of ASP.NET
pages.
46 | P a g e
TyBsc-IT 2024-2025
Source Code:
1) ViewState:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="viewstate" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
</form>
</body>
47 | P a g e
TyBsc-IT 2024-2025
</html>
Default.aspx.cs using
System; using
System.Collections.Gen
ric;
using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
48 | P a g e
TyBsc-IT 2024-2025
if
(!IsPostBack)
BSC_IT";
if
(ViewState["name"] ==
null)
ViewState["name"] = str;
sender, EventArgs e)
49 | P a g e
TyBsc-IT 2024-2025
Label1.Text = ViewState["name"].ToString();
OUTPUT:
2) Cookies
50 | P a g e
TyBsc-IT 2024-2025
Cookies.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Cookies.aspx.cs" Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<div>
AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="Red">Red</asp:ListItem>
<asp:ListItem Value="Green">Green</asp:ListItem>
<asp:ListItem Value="Yellow">Yellow</asp:ListItem>
<asp:ListItem Value="Pink">Pink</asp:ListItem>
<asp:ListItem Value="Orange">Orange</asp:ListItem>
51 | P a g e
TyBsc-IT 2024-2025
<asp:ListItem Value="Blue">Blue</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
Cookies.aspx.cs
using System;
using
System.Collections.Gene
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
52 | P a g e
TyBsc-IT 2024-2025
if
(!IsPostBack)
if
(Request.Cookies["BackgroundColor"] !=
null)
DropDownList1.SelectedValue =
Request.Cookies["BackgroundColor"].Value;
BodyTag.Style["background-color"] =
DropDownList1.SelectedValue;
protected void
53 | P a g e
TyBsc-IT 2024-2025
DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
BodyTag.Style["background-color"] =
DropDownList1.SelectedValue;
HttpCookie("BackgroundColor"); cookie.Value
= DropDownList1.SelectedValue;
cookie.Expires =
DateTime.Now.AddMilliseconds(5);
Response.Cookies.Add(cookie);
Response.SetCookie(cookie);
Output:
54 | P a g e
TyBsc-IT 2024-2025
3)Querystring
Querystring.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Querystring.aspx.cs"
Inherits="Querystring" %>
55 | P a g e
TyBsc-IT 2024-2025
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html
xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
</form>
</body>
</html>
56 | P a g e
TyBsc-IT 2024-2025
Querystring.aspx.cs
using System;
using
System.Collections.Gene
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
sender, EventArgs e)
57 | P a g e
TyBsc-IT 2024-2025
Response.Redirect("Default2.aspx?UserId=" + TextBox1.Text +
"&Password=" + TextBox2.Text);
Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
58 | P a g e
TyBsc-IT 2024-2025
<div>
</div>
</form>
</body>
</html>
Default2.aspx.cs
using System;
using
59 | P a g e
TyBsc-IT 2024-2025
System.Collections.Gene
System.Web.UI; using
System.Web.UI.WebCon
trols;
if
(!IsPostBack)
Label1.Text = Request.QueryString["UserId"];
Label2.Text = Request.QueryString["Password"];
60 | P a g e
TyBsc-IT 2024-2025
OUTPUT:
61 | P a g e
TyBsc-IT 2024-2025
62 | P a g e
TyBsc-IT 2024-2025
Golbal.aspx
<%@ Application Language="C#" %>
Application_Start(object sender,
EventArgs e)
Application["user"] = 0;
EventArgs e)
EventArgs e)
EventArgs e)
63 | P a g e
TyBsc-IT 2024-2025
Application.Lock();
Application["user"] = (int)Application["user"] + 1;
Application.UnLock();
EventArgs e)
Application.Lock();
Application["user"] = (int)Application["user"] - 1;
Application.UnLock();
</script>
Web.Config
<?xml version="1.0"?>
<!--
64 | P a g e
TyBsc-IT 2024-2025
-->
<configuration>
<system.web>
</system.web>
</configuration>
SessionApplicationt.aspx
<%@ Page Language="C#" AutoEventWireup="true"
65 | P a g e
TyBsc-IT 2024-2025
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
</form>
</body>
</html>
66 | P a g e
TyBsc-IT 2024-2025
OUTPUT:
67 | P a g e
TyBsc-IT 2024-2025
Practical No: 5A
Aim: Create a web application bind data in a multiline textbox by
querying in another textbox.
Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
TextMode="MultiLine"
</div>
</form>
</body>
</html>
Default.aspx.cs
using System
using
System.Collections.Gene
System.Web.UI; using
69 | P a g e
TyBsc-IT 2024-2025
System.Web.UI.WebCon
trols; using
System.Data.SqlClient; using
System.Configuration;
using System.Data;
sender, EventArgs e)
{ Stringconn=ConfigurationManager.ConnectionStrings["conn"].
SqlConnection(conn); con.Open();
SqlDataReader r = cmd.ExecuteReader();
while (r.Read())
TextBox2.Text +=
Environment.NewLine; for
TextBox2.Text += r[i].ToString().PadRight(10);
r.Close();
con.Close();
71 | P a g e
TyBsc-IT 2024-2025
Web.Config
<?xml version="1.0"?>
<!--
-->
<configuration>
<system.web>
</system.web>
<connectionStrings>
72 | P a g e
TyBsc-IT 2024-2025
2010\WebSites\WebSite1\App_Data\Database.mdf;Integrated
Security=True;User Instance=True" />
</connectionStrings>
</configuration>
OUTPUT:
73 | P a g e
TyBsc-IT 2024-2025
74 | P a g e
TyBsc-IT 2024-2025
Practical No: 5B
Aim: create an application to display records by using Database.
Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
75 | P a g e
TyBsc-IT 2024-2025
</div>
</form>
</body>
</html>
Default.aspx.cs using
System; using
System.Collections.Gen
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols; using
System.Data; using
System.Data.SqlClient;
using
76 | P a g e
TyBsc-IT 2024-2025
sender, EventArgs e)
String conn =
ConfigurationManager.ConnectionStrings["conn"].ConnectionSt
con.Open();
SqlDataReader r = cmd.ExecuteReader();
77 | P a g e
TyBsc-IT 2024-2025
while (r.Read())
"<br>";
r.Close();
con.Close();
78 | P a g e
TyBsc-IT 2024-2025
Web.Config
<?xml version="1.0"?>
<!--
-->
<configuration>
<system.web>
</system.web>
<connectionStrings>
79 | P a g e
TyBsc-IT 2024-2025
</connectionStrings>
</configuration>
OUTPUT:
80 | P a g e
TyBsc-IT 2024-2025
Practical No: 5C
Aim: Demonstrate the use of DataList link Control
Steps:
Source Code:
81 | P a g e
TyBsc-IT 2024-2025
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<ItemTemplate>
Id:
<br />
Name:
82 | P a g e
TyBsc-IT 2024-2025
<br />
Age:
<br />
Address:
<br />
<br />
</ItemTemplate>
</asp:DataList>
SelectCommand="SELECT * FROM
[Customer]"></asp:SqlDataSource>
</div>
</form>
</body>
83 | P a g e
TyBsc-IT 2024-2025
</html>
84 | P a g e
TyBsc-IT 2024-2025
85 | P a g e
TyBsc-IT 2024-2025
86 | P a g e
TyBsc-IT 2024-2025
OUTPUT:
87 | P a g e
TyBsc-IT 2024-2025
Practical No: 6A
Aim: Create a simple web page with various server controls to
demonstrate setting and use of their properties.(Example :
AutoPostBack) Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
88 | P a g e
TyBsc-IT 2024-2025
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<asp:DropDownList ID="DropDownList1"
runat="server"></asp:DropDownList><br /><br />
</div>
</form>
</body>
</html>
Default.aspx.cs
89 | P a g e
TyBsc-IT 2024-2025
System.Collections.Gene
ric;
using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols; using
System.Configuration;
using System.Data;
using
System.Data.SqlClient;
90 | P a g e
TyBsc-IT 2024-2025
if (IsPostBack ==
false)
string conn =
ConfigurationManager.ConnectionStrings["conn"].Conne
SqlConnection(conn); con.Open();
SqlDataReader r = cmd.ExecuteReader();
DropDownList1.DataSource = r;
DropDownList1.DataTextField = "city";
DropDownList1.DataBind();
r.Close();
con.Close();
91 | P a g e
TyBsc-IT 2024-2025
DropDownList1.SelectedValue; }
Web.config
<?xml version="1.0"?>
<!--
-->
92 | P a g e
TyBsc-IT 2024-2025
<configuration>
<system.web>
</system.web>
<connectionStrings>
</connectionStrings>
</configuration>
Output:-
93 | P a g e
TyBsc-IT 2024-2025
Practical No: 6B
Aim: Create a simple web page with various server controls to
demonstrate setting and use of their properties.(Example :
AutoPostBack) Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
<html xmlns="http://www.w3.org/1999/xhtml">
94 | P a g e
TyBsc-IT 2024-2025
<head runat="server">
<title></title>
</head>
<body>
<div>
<asp:DropDownList ID="DropDownList1"
runat="server"></asp:DropDownList><br /><br />
</div>
</form>
</body>
</html>
Default.aspx.cs
System.Collections.Gene
95 | P a g e
TyBsc-IT 2024-2025
ric;
using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
using
System.Configuration;
using System.Data;
using
System.Data.SqlClient;
96 | P a g e
TyBsc-IT 2024-2025
if (IsPostBack ==
false)
string conn =
ConfigurationManager.ConnectionStrings["conn"].Conne
SqlConnection(conn con.Open();
SqlDataReader r = cmd.ExecuteReader();
DropDownList1.DataSource = r;
DropDownList1.DataValueField = "city";
DropDownList1.DataTextField = "name";
DropDownList1.DataBind();
r.Close();
con.Close();
}
97 | P a g e
TyBsc-IT 2024-2025
sender, EventArgs e)
DropDownList1.SelectedValue; }
Web.config
<?xml version="1.0"?>
<!--
-->
<configuration>
<system.web>
98 | P a g e
TyBsc-IT 2024-2025
</system.web>
<connectionStrings>
</connectionStrings>
</configuration>
Output:-
99 | P a g e
TyBsc-IT 2024-2025
Practical No: 7A
Aim: Web Application to display data using Disconnected Data Access
and Data Binding using GridView control Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
100 | P a g e
TyBsc-IT 2024-2025
<div>
/>
BorderColor="#E7E7FF" BorderStyle="None"
BorderWidth="1px" CellPadding="3"
GridLines="Horizontal">
101 | P a g e
TyBsc-IT 2024-2025
</div>
</form>
</body>
</html>
Default.aspx.cs
System.Collections.
G eneric; using
System.Linq; using
System.Web; using
System.Web.UI;
using
102 | P a g e
TyBsc-IT 2024-2025
n; using
System.Data;
using
System.Data.SqlClien
t;
protected void
Button1_Click(object sender,
EventArgs e)
103 | P a g e
TyBsc-IT 2024-2025
string conn =
ConfigurationManager.ConnectionStrings["conn"].Con
nectionString;
SqlDataAdapter(); DataSet ds
= new DataSet();
sda.SelectCommand = cmd;
sda.Fill(ds, "CustomerCopy");
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
Web.config
<?xml version="1.0"?>
104 | P a g e
TyBsc-IT 2024-2025
<!--
-->
<configuration>
<system.web>
</system.web>
<connectionStrings>
</connectionStrings>
</configuration>
105 | P a g e
TyBsc-IT 2024-2025
OUTPUT:
Practical No: 7B
Aim: Web Application to display data using Disconnected Data Access
and Data Binding using FormView control Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default" %>
106 | P a g e
TyBsc-IT 2024-2025
<head runat="server">
<title></title>
</head>
<body>
<div>
<EditItemTemplate>
id:
<br />
name:
107 | P a g e
TyBsc-IT 2024-2025
<br />
mobile_no:
<br />
city:
<br />
state:
<br />
country:
<br />
108 | P a g e
TyBsc-IT 2024-2025
CausesValidation="False" CommandName="Cancel"
Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
id:
<br />
name:
<br />
mobile_no:
<br />
109 | P a g e
TyBsc-IT 2024-2025
city:
<br />
state:
<br />
country:
<br />
<asp:LinkButton ID="InsertCancelButton"
runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel" />
110 | P a g e
TyBsc-IT 2024-2025
</InsertItemTemplate>
<ItemTemplate>
id:
<br />
name:
<br />
mobile_no:
<br />
city:
<br />
state:
111 | P a g e
TyBsc-IT 2024-2025
<br />
country:
</ItemTemplate>
</asp:FormView>
ConnectionString="<%$ ConnectionStrings:ConnectionString
%>"
SelectCommand="SELECT * FROM
[cust]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
112 | P a g e
TyBsc-IT 2024-2025
Next->
113 | P a g e
TyBsc-IT 2024-2025
114 | P a g e
TyBsc-IT 2024-2025
115 | P a g e
TyBsc-IT 2024-2025
OUTPUT:-
116 | P a g e
TyBsc-IT 2024-2025
Practical No: 7C
Aim: Web Application to display data using Disconnected Data Access
and Data Binding using DetailView control Source Code:
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView ID="DetailsView1" runat="server"
Height="50px" Width="125px"
AutoGenerateRows="False" DataSourceID="SqlDataSource1">
<Fields>
117 | P a g e
TyBsc-IT 2024-2025
</html>
119 | P a g e
TyBsc-IT 2024-2025
120 | P a g e
TyBsc-IT 2024-2025
OUTPUT:-
Practical No: 8A
Aim: Create a web application to demonstrate from security and windows
security with proper authentication and authorization properties.
Source Code:
Default1.aspx
<%@ Page Language="C#" AutoEventWireup="true"
121 | P a g e
TyBsc-IT 2024-2025
html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
122 | P a g e
TyBsc-IT 2024-2025
</form>
</body>
</html>
Default1.aspx.cs using
System; using
System.Collections.Generic
System.Web; using
System.Web.UI; using
System.Web.UI.WebControls;
System.Web.UI.Page
}
123 | P a g e
TyBsc-IT 2024-2025
protected bool
pass)
if(uname ==
"Snehal")
if (pass ==
"123")
retrun true;
if (uname ==
"mayur")
if (pass ==
124 | P a g e
TyBsc-IT 2024-2025
"456")
return true;
if (uname ==
"Asmit")
if (pass ==
"789")
return true;
if (uname ==
"Sunny")
if (pass ==
"sunny123")
return true;
125 | P a g e
TyBsc-IT 2024-2025
if (uname ==
"Aman")
if (pass ==
"aman123")
return true;
return false;
protected void
Button1_Click(object sender,
EventArgs e)
if (authenticate(TextBox1.Text,
TextBox2.Text))
126 | P a g e
TyBsc-IT 2024-2025
{
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text,
CheckBox1.Checked);
Session["username"] = TextBox1.Text;
Response.Redirect("Default2.aspx");
else
Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
127 | P a g e
TyBsc-IT 2024-2025
</head>
<body>
<div>
</div>
</form>
</body>
</html>
128 | P a g e
TyBsc-IT 2024-2025
Default2.aspx.cs
using System; using
System.Collections.
G eneric; using
System.Linq; using
System.Web; using
System.Web.UI;
using
System.Web.UI.Web
Controls;
if
(Session["username"]
129 | P a g e
TyBsc-IT 2024-2025
!=null)
Web.config
<?xml version="1.0"?>
<!--
130 | P a g e
TyBsc-IT 2024-2025
-->
<configuration>
<system.web>
<authentication mode="Forms">
</forms>
</authentication>
<authorization>
<allow users="?"/>
<deny users="?"/>
</authorization>
</system.web>
131 | P a g e
TyBsc-IT 2024-2025
</configuration>
OUTPUT:
132 | P a g e
TyBsc-IT 2024-2025
Practical No: 8B
Aim: create a web application to demonstrate use of various Ajax
Controls.
Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
133 | P a g e
TyBsc-IT 2024-2025
<head runat="server">
<title></title>
</head>
<body>
<div>
<asp:ScriptManager ID="ScriptManager1"
runat="server"></asp:ScriptManager>
<ajaxToolkit:HtmlEditorExtender ID="HtmlEditorExtender1"
runat="server" EnableSanitization="False"
TargetControlID="Textbox1"></ajaxToolkit:HtmlEditorExtender>
</div>
</form>
</body>
</html>
134 | P a g e
TyBsc-IT 2024-2025
OUTPUT:
135 | P a g e
TyBsc-IT 2024-2025
Practical No : 9
Aim: Program to create and use DLL.
Steps:
In Visual Studio -> file -> new -> Project -> select Class Library
Source Code:
ClassLibrary2.Class1 using
System;
usingSystem.Collection
s.Generic; using
System.Linq;
using System.Text;
namespace
ClassLibrary2
136 | P a g e
TyBsc-IT 2024-2025
public string
UpperConvert(string text)
return
text.ToUpper();
public string
LowerConvert(string text)
return
text.ToLower();
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
137 | P a g e
TyBsc-IT 2024-2025
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
</form>
</body>
</html>
138 | P a g e
TyBsc-IT 2024-2025
Right Click on your website -> Add Reference Then browse to the
ClassLibrary1.dll file you created. Default.aspx.cs
System.Web.UI.WebControls;
class _Default :
System.Web.UI.Page
{ } protected void
TextBox1.Text =
t.UpperConvert(TextBox1.Text); } protected
139 | P a g e
TyBsc-IT 2024-2025
TextBox1.Text = t.LowerConvert(TextBox1.Text);
140 | P a g e
TyBsc-IT 2024-2025
OUTPUT:
141 | P a g e
TyBsc-IT 2024-2025
Practical No : 10
Aim: Create a web application for User defined exception handling.
Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
a: <asp:TextBox ID="TextBox1"
142 | P a g e
TyBsc-IT 2024-2025
b: <asp:TextBox ID="TextBox2"
</div>
</form>
</body>
</html>
Default.aspx.cs
using System;
using
System.Collections.Gene
143 | P a g e
TyBsc-IT 2024-2025
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;
sender, EventArgs e)
try
144 | P a g e
TyBsc-IT 2024-2025
decimal a, b, result;
a=
Decimal.Parse(TextBox1.Text);
b=
Decimal.Parse(TextBox2.Text);
result = a / b;
Label1.Text = result.ToString();
Label1.ForeColor = System.Drawing.Color.Black;
Label1.Text += "<br/>";
Label1.Text += "<br/>";
145 | P a g e
TyBsc-IT 2024-2025
Label1.ForeColor = System.Drawing.Color.Red;
OUTPUT:
146 | P a g e