You are on page 1of 11

T.Y.B.SC(I.T.

)-ADVANCED WEB PROGRAMMING-PAPER(III)


IT-7239
2018-2019

Practical 5
Working with Navigation, Beautification and Master Page.

A)Create Web Form to demonstrate use of Website Navigation controls


and Site Map.

Program-

Default.aspx-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>List of Courses</h1>
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:Menu>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</div>
</form>
</body>
</html>

Default2.aspx-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>

P a g e 1 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

<asp:SiteMapPath ID="SiteMapPath1" runat="server">


</asp:SiteMapPath>
<h1>Welcome to BSc-IT WebPage</h1>
</div>
</form>
</body>
</html>

Default3.aspx-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs"
Inherits="Default3" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
<h1>Welcome to BSc-CS WebPage</h1>
</div>
</form>
</body>
</html>

Default4.aspx-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs"
Inherits="Default4" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
<h1>Welcome to BSc WebPage</h1>
</div>
</form>
</body>
</html>
P a g e 2 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

Web.sitemap-
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Default.aspx" title="COURSE" description="">
<siteMapNode url="Default2.aspx" title="BSc-IT" description="" />
<siteMapNode url="Default3.aspx" title="BSc-CS" description="" />
<siteMapNode url="Default4.aspx" title="BSc" description="" />
</siteMapNode>
</siteMap>

Output-

P a g e 3 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

B) Create a web application to demonstrate use of Master page with


applying Styles and Themes for page beautification.

Program-

MasterPage.master-
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs"
Inherits="MasterPage" %>
<!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>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">

P a g e 4 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

.style1
{
width: 90px;
height: 50px;
text-align:center;
}
#header
{
text-align:center;
background-color:Lime;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1 id="header">Our official WebSite.</h1>
<table align="center">
<tr>
<td class="style1"><asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Default.aspx">First Page</asp:HyperLink></td>
<td class="style1"><asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="~/Default2.aspx">Second Page</asp:HyperLink></td>
</tr>
</table>
<asp:ContentPlaceHolder id="ContentPlaceHolder1"
runat="server"></asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

Default.aspx-
<%@ Page Title="" Theme="Theme1" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.s1{font-weight:bolder;font-style:italic;text-align:center;background-color:Aqua;}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1 class="s1">Welcome to 1st page of our WebSite</h1>
<asp:Button SkinID="BLUE" ID="Button1" runat="server" Text="Button" />
<asp:Button SkinID="ORANGE" ID="Button2" runat="server" Text="Button" />
</asp:Content>

Default2.aspx-
P a g e 5 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

<%@ Page Title="" Theme="Theme1" Language="C#" MasterPageFile="~/MasterPage.master"


AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.s1{font-weight:bolder;font-style:italic;text-align:center;background-color:Orange;}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1 class="s1">Welcome to 2nd page of our WebSite</h1>
<asp:Button SkinID="RED" ID="Button1" runat="server" Text="Button" />
<asp:Button SkinID="YELLOW" ID="Button2" runat="server" Text="Button" />
</asp:Content>

SkinFile1.skin-
<asp:Button SkinID="RED" runat="server" Text="RED" BackColor="Red" BorderColor="Black"
/>
<asp:Button SkinID="YELLOW" runat="server" Text="YELLOW" BackColor="Yellow"
BorderColor="Black" />
<asp:Button SkinID="BLUE" runat="server" Text="BLUE" BackColor="#0066FF"
BorderColor="Black" />
<asp:Button SkinID="ORANGE" runat="server" Text="ORANGE" BackColor="#FF9900"
BorderColor="Black" />

Output-

P a g e 6 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

C)Create a web application to demonstrate various states of ASP.NET


Pages.

Program-

5c.aspx-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="5c.aspx.cs" Inherits="_5c" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div align="center">

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


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Last Name:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Restore"
onclick="Button2_Click" />

<asp:Button ID="Button4" runat="server" onclick="Button4_Click" Text="Cookie" />


<br />
<br />
<asp:Button ID="Button3" runat="server" onclick="Button3_Click"
Text="Increment" />
<br />
P a g e 7 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

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


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

Design-

5c.aspx.cs-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _5c : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["fn"] = TextBox1.Text;
ViewState["ln"] = TextBox2.Text;
TextBox1.Text = TextBox2.Text = string.Empty;
}
protected void Button2_Click(object sender, EventArgs e)
{
if (ViewState["fn"] != null)
{
TextBox1.Text = ViewState["fn"].ToString();
}
if (ViewState["ln"] != null)
{
TextBox2.Text = ViewState["ln"].ToString();
}
}
protected void Button3_Click(object sender, EventArgs e)
P a g e 8 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

{
int counter;
if (ViewState["Counter"] == null)
{
counter = 1;
}
else
{
counter = (int)ViewState["Counter"] + 1;
}
ViewState["Counter"] = counter;
Label3.Text = "Counter :" + counter.ToString();
}
protected void Button4_Click(object sender, EventArgs e)
{
HttpCookie h = new HttpCookie("fn");
h.Value = TextBox1.Text;
Response.Cookies.Add(h);
Response.Redirect("CookiePage.aspx");
}
}

CookiePage.aspx-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CookiePage.aspx.cs"
Inherits="CookiePage" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

CookiePage.aspx.cs-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

P a g e 9 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

using System.Web.UI.WebControls;
public partial class CookiePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["fn"] != null)
{
Response.Write("Welcome " + Request.Cookies["fn"].Value);
}
}
}
Output-

After clicking on Submit button-

After clicking on Restore button-

After clicking on Cookie button-

P a g e 10 | 11
T.Y.B.SC(I.T.)-ADVANCED WEB PROGRAMMING-PAPER(III)
IT-7239
2018-2019

After clicking on Increment button 1 time-

P a g e 11 | 11

You might also like