0% found this document useful (0 votes)
23 views59 pages

AWP (Own)

Uploaded by

devbhatth69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views59 pages

AWP (Own)

Uploaded by

devbhatth69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Malini Kishor Sanghvi College TYBScIT Sem 5

SR.NO DATE PRACTICAL SIGN


1A Write a program to create an
application to print on screen the
output of adding, subtracting,
multiplying and dividing two
numbers entered by the user in C#.
1B Write a program to create an
application to print Floyd's triangle
till n rows in C#.
1C Write a program to create an
application to demonstrate
following operations.
i. Generate Fibonacci series.
ii. Test for prime numbers
2A Write a program to create a simple
application to demonstrate the
concepts boxing and unboxing.
2B Write a program to create a simple
application to perform addition
and subtraction using delegate.
2C Write a program to create a simple
application to demonstrate use of
the concepts of interfaces.
3A Write a program to create a simple
web page with various server
controls to demonstrate setting and
use of their
properties. (Example:
AutoPostBack)
3B Write a program to create a simple
application to demonstrate your
vacation using calendar control.

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

3C Write a program to Ddemonstrate


the use of Treeview operations
on the web form.
4A Write a program to create a
Registration form to demonstrate
use of various Validation controls.
4B Write a program to create Web
Form to demonstrate use of
Adrotator Control.
4C Write a program to create Web
Form to demonstrate
use User Controls.

5A Write a program to create Web


Form to demonstrate use of
Website Navigation controls.
5B Write a program to create a web
application to demonstrate use of
Master Page and content page.
6A Write a program to create a web
application for inserting and
deleting records from a database.
6B Write a program to Create a web
application to display Using
Disconnected Data Access and
Databinding using GridView.
7 Write a program to create a web
application to demonstrate the use
of different types of cookies.

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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;

protected void Page_Load(object sender, EventArgs e)


{

protected void Button2_Click(object sender, EventArgs e)


{
v1 = int.Parse(TextBox1.Text);
v2 = int.Parse(TextBox2.Text);

res = (v1 - v2);


Label2.Text = res.ToString();
}

protected void Button3_Click(object sender, EventArgs e)


{
v1 = int.Parse(TextBox1.Text);
v2 = int.Parse(TextBox2.Text);

res = (v1 * v2);


Label3.Text = res.ToString();
}

protected void Button4_Click(object sender, EventArgs e)


{
val1 = double.Parse(TextBox1.Text);
val2 = double.Parse(TextBox2.Text);

result = (val1 / val2);


Label4.Text = result.ToString();
}

protected void Button1_Click(object sender, EventArgs e)


{
v1 = int.Parse(TextBox1.Text);
v2 = int.Parse(TextBox2.Text);

res = (v1 + v2);


Label1.Text = res.ToString();
}
}
}

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
Output:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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();
}
}

public static void Main()


{
Console.WriteLine("dev bhatt 103");
printFloydTriangle(5);
}
}
Output:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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)
{

protected void Button1_Click(object sender, EventArgs e)


{
int n = int.Parse(TextBox1.Text);
int a = 0, b = 1, c;
for (int i = 0; i < n; i++)
{
TextBox2.Text += $"{a} ";
c = a + b;
a = b;
b = c;
}
}

protected void Button2_Click(object sender, EventArgs e)


{
string vow = TextBox1.Text.ToLower();
List<string> Vowel = new List<string>();
Vowel.Add("a");
Vowel.Add("e");
Vowel.Add("i");
Vowel.Add("o");
Vowel.Add("u");
foreach (string a in Vowel)
{
if (vow == "a" || vow == "e" || vow == "i" || vow == "o" || vow == "u")
{
TextBox3.Text = "Result " + vow + " is a vowel";
break;
}
else
{
TextBox3.Text = "Result " + vow + " is not a vowel";
break;
}
}

protected void Button3_Click(object sender, EventArgs e)


{
int n = int.Parse(TextBox1.Text);
bool flag = true;
if (n < 2)
TextBox4.Text = "it is a not prime number";
flag = false;
for (int i = 2; i * i >= n; i++)

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
{
if (n % i == 0)
TextBox4.Text = "it is a not prime number";
flag = false;
}
if (flag == true)
TextBox4.Text = "it is a prime number";
}

protected void Button4_Click(object sender, EventArgs e)


{
string orstring = TextBox1.Text;
char[] c = orstring.ToCharArray();
Array.Reverse(c);
TextBox5.Text = new string(c);
}
}
}

Output:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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);
}
}
}

class c : iface1, iface2


{
a obj1 = new a();
b obj2 = new b();
public void languages()
{
obj1.languages();
}
public void courses()

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
{
obj2.courses();
}
}
static void Main(string[] args)
{
c obj = new c();
obj.languages();
obj.courses();
Console.ReadLine();
}
}
}

Output:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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)
{

protected void Button1_Click(object sender, EventArgs e)


{
string Fname = TextBox1.Text;
string Lname = TextBox2.Text;
string year = "None";
if (op1.Checked)
{
year = "Frist year";
}
if (op2.Checked)
{
year = "Second year";
}
if (op3.Checked)
{
year = "Third year";
}

TextBox4.Text = $"{Fname} {Lname} you have succesfully enrolled in {year}";


}
}
}

Output:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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

public partial class WebForm1 : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)

if ((e.Day.Date >= new DateTime(2024, 9, 10)) && (e.Day.Date <= new DateTime(2024, 9,
20)))

e.Cell.BackColor = System.Drawing.Color.LightGreen;

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Output:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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

public partial class WebForm1 : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)

Response.Write("you have selected the option : " + TreeView1.SelectedValue);

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Output :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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>

<form id="form1" runat="server">

<div>

<asp:Label ID="Label1" runat="server" Text="user ID"></asp:Label>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"


ControlToValidate="TextBox1" ErrorMessage="* User Id required "
ForeColor="#FF3300"></asp:RequiredFieldValidator>

<br />

<br />

<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"


ControlToValidate="TextBox2" ErrorMessage="* Password required "
ForeColor="#FF3300"></asp:RequiredFieldValidator>

<br />

<br />

<asp:Label ID="Label3" runat="server" Text="Confirm password"></asp:Label>

<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"


ControlToValidate="TextBox3" ErrorMessage="* Confirm password required "
ForeColor="#FF3300"></asp:RequiredFieldValidator>

<br />

<br />

<asp:Label ID="Label4" runat="server" Text="Email ID"></asp:Label>

<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"


ControlToValidate="TextBox4" ErrorMessage="* Email ID required "
ForeColor="#FF3300"></asp:RequiredFieldValidator>

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
<br />

<br />

<asp:Label ID="Label5" runat="server" Text="Mobile Number"></asp:Label>

<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"


ControlToValidate="TextBox5" ErrorMessage="* Mobile Number required "
ForeColor="#FF3300"></asp:RequiredFieldValidator>

<br />

</div>

<asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Size="Medium" Height="72px"


Text="Summit" Width="860px" />

</form>

<p>

dev bhatt 103</p>

</body>

</html>

Output:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
Redirects to:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Practical No : 4 (C)
Question : Create Web Form to demonstrate use User Controls.
Add -> New Item -> Web User Control

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs"


Inherits="prac4c.WebUserControl1" %>

<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)

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
{

protected void btnSubmit_Click(object sender, EventArgs e)


{
lblMessage.Text = lblMessage.Text + txtName.Text;
}
}
}

}Add -> New Item -> WebForm1.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="prac4c.WebForm1" %>
<%@ Register Src="~/WebUserControl1.ascx" TagPrefix="uc" TagName="MyUserControl" %>
<!DOCTYPE html>

<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 :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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" />

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
</asp:SiteMapPath>
<br/>
<br />
<asp:Label ID="Label1" runat="server" Font-Size="XX-Large" Text="This is Contact Us
page"></asp:Label>
<br />
<br />
dev bhatt 103
<div>
</div>
</form>
</body>
</html>
ABOUT.ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="prac5a.WebForm2"
%>

<!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 />
&nbsp;<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" />

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
<PathSeparatorStyle Font-Bold="True" ForeColor="#990000" />
<RootNodeStyle Font-Bold="True" ForeColor="#FF8000" />
</asp:SiteMapPath>
<br />
<br />
<asp:Label ID="Label1" runat="server" Font-Size="XX-Large" Text="This is About our team
page"></asp:Label>
<br />
<br />
dev bhatt 103</div>
</form>
</body>
</html>

WEB.CONFIG :
<?xml version="1.0" encoding="utf-8"?>

<configuration>

<system.web>

<compilation debug="true" targetFramework="4.7.2" />

<httpRuntime targetFramework="4.7.2" />

<siteMap defaultProvider="XmlSiteMapProvider">

<providers>

<add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider"


siteMapFile="~/Web.sitemap" />

</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 url="~/Home.aspx" title="Home" description="">

<siteMapNode url="~/About.aspx" title="About Us" description="Second page">

<siteMapNode url="~/Team.aspx" title="About Our Team" description="Information


about our team" />

<siteMapNode url="~/History.aspx" title="About Our History"


description="Information about our history" />

</siteMapNode>

<siteMapNode url="~/Contact.aspx" title="Contact Us" description="Contact information"


/>

</siteMapNode>

</siteMap>

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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>

<body style="height: 558px">

<form id="form1" runat="server">

<div>

<asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6"


DataSourceID="SiteMapDataSource1" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" StaticSubMenuIndent="10px">

<DynamicHoverStyle BackColor="#990000" ForeColor="White" />

<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />

<DynamicMenuStyle BackColor="#FFFBD6" />

<DynamicSelectedStyle BackColor="#FFCC66" />

<StaticHoverStyle BackColor="#990000" ForeColor="White" />

<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />

<StaticSelectedStyle BackColor="#FFCC66" />

</asp:Menu>

<br />

</div>

<p>

dev bhatt 103</p>

<br />

<br />

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

</form>

</body>

</html>

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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>

<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" />

<PathSeparatorStyle Font-Bold="True" ForeColor="#990000" />

<RootNodeStyle Font-Bold="True" ForeColor="#FF8000" />

</asp:SiteMapPath>

</div>

<p>

<asp:Label ID="Label1" runat="server" Font-Size="XX-Large" Text="This is Our history


page"></asp:Label>

</p>

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
<p>

&nbsp;</p>

<p>

dev bhatt 103</p>

</form>

</body>

</html>

OUTPUT :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

PRACTICAL NO.5 (B):


QUESTION: Write a code to Create a web application to demonstrate use of
Master Page and content page.
CODE:
1. Add a Master Page
 Right-click on the project in Solution Explorer.
 Select Add > New Item.
 Choose Master Page and name it Site.master.
 Click Add.

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>

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
<h1>Badminton: A Sport of Strategy, Speed, and Skill!</h1>
<nav>
<a href="Default.aspx">Home</a> |
<a href="About.aspx">About</a> |
<a href="Contacts.aspx">Contact</a>
</nav>
</header>
<hr />
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
<footer>
<hr />
<p>Footer <strong>© 2024 Badminton: A Sport of Strategy, Speed, and Skill</strong><br />
<strong>All Rights Reserved.</strong></p>
<p>Dev bhatt 103 </p>
</footer>
</div> </form> </body> </html>

2. Add a Content Page


 Right-click on the project in Solution Explorer.
 Select Add > New Item.
 Choose Web Form using Master Page and name it Default.aspx.
 Click Add.
 In the dialog that appears, choose the Site.master file as the master page

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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:

3. Add Another Content Page


 Add another page by following the same steps, and name it About.aspx and
Contact.aspx add some custom content.
About.aspx:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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 :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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>

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
DESIGN :

NOTE : At last, right click on Default.aspx and select set as start page.

OUTPUT:

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Page after you click About :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
Page after you click Contact :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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 .

Step 2: Set Up the Database (SQL Server):


1. Open SQL Server Management Studio (SSMS) or use the built-in SQL Server Express in Visual
Studio.
2. Create a new database : By , Right-click on Databases in SSMS and choose New Database.

Name the database CustomerDB

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

3. Create a new table in the CustomerDB database:


Expand the CustomerDB node, right-click Tables, and select Add New Table.

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

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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.

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Now Go to the Views option in Taskbar Select > Server Explorer Window

Now right click on Data Connections and Select Add Connection

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

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Click on Test Connection and it will say Test Connection Succeeded.

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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

The following window appears and just click OK and proceed.

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
Now here , add Connection of your database and click Next and proceed.

In this window , click on Advanced

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Output :

When you Click on New the following table appears :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Insert new data and click on insert

You can see data has been Inserted :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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)
)

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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.

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Insert a few sample records like shown below in the image

Add the Connection String in Web.config:


In order to connect to the SQL database from the web application, you need to define a connection string.
In Solution Explorer, open the Web.config file.
Add the following inside the <configuration> element, specifying the connection string for your database :
<connectionStrings><add name ="DemoDBConnectionString" connectionString ="Data
Source=(localdb)\MSSQLLocalDB;Initial Catlog=DemoDB;Integrated Security =True"
providerName="System.Data.SqlClient"/></connectionStrings>

Now Add->WebForm and name it. Eg mine is [Demo.aspx]

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"


Inherits="prac6b.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>User List</title>
</head>

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
<body>
<form id="form1" runat="server">
<div>
<h2>User List</h2>
<asp:GridView ID="Grid" runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>

Design :

Now write the following code in Demo.aspx.cs :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace prac6b
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridView();
}
}

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
private void BindGridView()
{
string connectionString =
System.Configuration.ConfigurationManager.ConnectionStrings["DemoDBConnectionStrin
g"].ConnectionString;
string query = "SELECT Id, Name, Email FROM [dbo].[Table]"; // Use square
brackets

using (SqlConnection connection = new SqlConnection(connectionString))


{
SqlDataAdapter dataAdapter = new SqlDataAdapter(query, connection);
DataSet dataSet = new DataSet();

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 :

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

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");

// Assigning value to the created cookie


creatorCookie.Value = "Dev bhatt 103";

// Adding Cookie to the response instance


Response.Cookies.Add(creatorCookie);

// Retrieving the value of the cookie


string author = Response.Cookies["creator"].Value;
Label2.Text = author;

// Expiring the second cookie if it exists


if (Request.Cookies["comp"] != null)
{
Response.Cookies["comp"].Expires = DateTime.Now.AddDays(-1);
}

protected void Button1_Click(object sender, EventArgs e)


{
Label3.Text = "";
// Adding Cookies
if (apple.Checked)
Response.Cookies["comp"]["apple"] = "apple";
if (dell.Checked)
Response.Cookies["comp"]["dell"] = "dell";
if (lenevo.Checked)
Response.Cookies["comp"]["lenevo"] = "lenevo";
if (acer.Checked)
Response.Cookies["comp"]["acer"] = "acer";
if (sony.Checked)
Response.Cookies["comp"]["sony"] = "sony";
if (wipro.Checked)
Response.Cookies["comp"]["wipro"] = "wipro";
// Fetching Cookies
if (Request.Cookies["comp"] != null)
{
foreach (string key in Request.Cookies["comp"].Values)
{
Label3.Text += Request.Cookies["comp"][key] + " ";
}

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5
}
}
}

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>

<h2>Set Creator Cookie</h2>


<asp:Label ID="Label2" runat="server" Text=""></asp:Label>

<h2>Select Your Preferred Computer Brands</h2>


<asp:CheckBox ID="apple" runat="server" Text="Apple" />
<asp:CheckBox ID="dell" runat="server" Text="Dell" />
<asp:CheckBox ID="lenevo" runat="server" Text="Lenovo" />
<asp:CheckBox ID="acer" runat="server" Text="Acer" />
<asp:CheckBox ID="sony" runat="server" Text="Sony" />
<asp:CheckBox ID="wipro" runat="server" Text="Wipro" />

<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />


<br /><br />

<asp:Label ID="Label3" runat="server" Text=""></asp:Label>


</div>
</form>
</body>
</html>

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Dev Hitesh bhatt 103 Advanced Web Development


Malini Kishor Sanghvi College TYBScIT Sem 5

Dev Hitesh bhatt 103 Advanced Web Development

You might also like