0% found this document useful (0 votes)
102 views

Lovely Professional University: Declaration

The document is a homework assignment submitted by a student named Rohitt Sharma. It contains instructions for two questions to create a website. The first question asks to create a master page and content page that uses the master page and displays a company logo. The second question asks to create a website that allows users to select different themes (green or pink) that change the appearance of the page.

Uploaded by

Rohitt Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

Lovely Professional University: Declaration

The document is a homework assignment submitted by a student named Rohitt Sharma. It contains instructions for two questions to create a website. The first question asks to create a master page and content page that uses the master page and displays a company logo. The second question asks to create a website that allows users to select different themes (green or pink) that change the appearance of the page.

Uploaded by

Rohitt Sharma
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 15

LOVELY PROFESSIONAL UNIVERSITY

Homework Title/No. : Home Work 3 Course Code: INT-402

Course Instructor: N. Priyanka Course Tutor: N. Priyanka

Date of Allotment: 21-03-2011 Date of submission: 04-04-2011

Student’s Roll No. : RG17M1A20 Section No. : DE533

Declaration:
I declare that this assignment is my individual work. I have not copied from any other student’s work
or from any other source except where due acknowledgement is made explicitly in the text, nor has
any part been written for me by another person.

Student’s Signature: Rohitt Sharma

Evaluator’s comments:
_________________________________________________________________________________
Marks obtained: ______________________ out of ________________________________________
Part A

1. Create a Master Page for a company’s website which contains an image that is
logo for the company. It must be located in a folder named Master Pages. Also
create a Content Page which uses the Master Page and correctly displays the
website logo. Place the Content Page in a completely different folder. Register
the Master Page in web configuration file.

Ans: -

MasterPage.master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs"


Inherits="Master_Pages_MasterPage" %>

<table align="center" border="2">


<tr>
<td>
<h1>Hello EveryOne...</h1>
</td>
<td align="center">
<asp:Image ID="Image1" runat="server" Height="113px"
ImageUrl="~/images/1.jpg" />
</td>
</tr>
<tr>
<td >
<asp:HyperLink ID="HyperLink1" runat="server">Home</asp:HyperLink>
</td>
<td rowspan="3"> <asp:ContentPlaceHolder id="ContentPlaceHolder1"
runat="server">

</asp:ContentPlaceHolder></td>
</tr>
<tr>
<td >

<asp:HyperLink ID="HyperLink2" runat="server">About</asp:HyperLink>


</td></tr>
<tr>

<td >
<asp:HyperLink ID="HyperLink3" runat="server">Contact Us</asp:HyperLink>
</td>
</tr>
</table>

content.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="content.aspx.cs"


Inherits="_Default" %>

<asp:content id="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" >


<table width="100%" >

<tr>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/3.jpg"/>
</td>
</tr>
</table>
</asp:content>

web.config

<system.web>
<pages masterPageFile="~/Master Pages/MasterPage.master">
</pages>
</system.web>

Result:-

2. Make a Website in which users of your website are allowed to customize the
appearance of your website by selecting different Themes. Some users might prefer
a green theme and other website users might prefer a pink Theme. The start page of
your website contains two HyperLink Controls. Which applies either green Theme
or the pink Theme to the page depending on which link they click on the page body?

Ans: -

Theme.aspx

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


<div>
<table width="80%" align="center">
<tr>
<td colspan="2" align="center">
<asp:Label ID="Label2" runat="server" Text="HELLO
EVERYONE..."></asp:Label></td>
</tr>
<tr>
<td >
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/green.aspx" >Green
</asp:HyperLink>
</td>

<td align="right">
<asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="~/pink.aspx">Pink</asp:HyperLink>
</td>
</tr>
<tr>
<td align="center" colspan="2" >
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Choose Theme And View the
Effect"></asp:Label>

</td>
</tr>
</table>

</div>
</form>

Theme.aspx.cs
protected void Page_PreInit(object sender, EventArgs e)
{

if (Session["bg"] != null)
{
Page.Theme = Session["bg"].ToString();

}
}
Green.aspx.cs

protected void Page_Load(object sender, EventArgs e)


{

Session["bg"] = "green";

Response.Redirect("Theme.aspx");

pink.aspx.cs

protected void Page_Load(object sender, EventArgs e)


{

Session["bg"] = "pink";

Response.Redirect("Theme.aspx");

Green.skin

<asp:Label Runat="server" ForeColor="Green" Font-Names="Comic Sans MS" Font-


Size="X-Large" />

Green.css

body
{
background-image:url('green.jpg');
}

pink.skin

<asp:Label runat="server" ForeColor="Pink" BackColor="AntiqueWhite" Font-Bold Font-


Names="Algerian" Font-Size="X-Large" />

pink.css
body
{
background-image:url('pink.jpg');
}

Result-
3. Make a TreeView Control which is populated using an XML file. This XML file is
divided into four categories of available options: Motherboard, Memory,
HardDrives and Drives. These options further provide sub options for additional
information of the parent option. Create a hierarchical list in such a way that
enables users to select multiple options from the list in order to receive additional
information about them. In order to do so, apply the CheckBox controls next to the
leaf nodes within the hierarchical list of nodes. Bind the TreeView Control to this
XML file.

Ans: -

XMLFile.xml

<?xml version="1.0" encoding="utf-8" ?>


<Hardwares>
<Item Name="MotherBoard">
<ItemValue Value="ACube Systems">
</ItemValue>
<ItemValue Value="ASRock">
</ItemValue>
</Item>
<Item Name="Memory">
<ItemValue Value="Adtec">
</ItemValue>
<ItemValue Value="Asus">
</ItemValue>
</Item>
<Item Name="HardDrives">
<ItemValue Value="Toshiba">
</ItemValue>
<ItemValue Value="Western Digital">
</ItemValue>
</Item>
<Item Name="Drives">
<ItemValue Value="Floppy Drive">
</ItemValue>
</Item>
</Hardwares>

Default.aspx
<div>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="XmlDataSource1"
ImageSet="BulletedList" ShowExpandCollapse="False">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD"
HorizontalPadding="0px" VerticalPadding="0px" />
<DataBindings>
<asp:TreeNodeBinding DataMember="Item" ValueField="Name" />
<asp:TreeNodeBinding DataMember="ItemValue" ShowCheckBox="True"
ValueField="Value" />
</DataBindings>
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
HorizontalPadding="0px" NodeSpacing="0px" VerticalPadding="0px" />
</asp:TreeView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml">
</asp:XmlDataSource>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Show Info" />
<br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
<br />
</div>

Default.aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{

TreeNodeCollection abc=TreeView1.CheckedNodes;
foreach (TreeNode node in abc)
{

Label1.Text += node.ValuePath + "<br/>";


}
}
OUTPUT

Part B
4. Make a Website in which users are allowed to select the background colour according
to their preference. In future, whenever they visit the WebSite, the chosen
background colour must appear in the WebPage. In order to do so, use the concept
of Session state and save the Session state in a Microsoft SQL Server database.

Ans: -

Default.aspx

<table width="90%" align="center" style="height: 150px">


<tr>
<td align="center" colspan="2">
<h1 style="font-family:Algerian">Welcome everyone</h1>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:Image ID="Image1" runat="server" ImageUrl="~/1.jpg" />
</td>

</tr>
<tr>

<td align="center" colspan="2">


<asp:Label ID="Label1" runat="server" Text="Enter Your Name"></asp:Label>
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Login" onclick="btn_Click" />

</td>

</tr>
</table>

Default.aspx.cs

protected void btn_Click(object sender, EventArgs e)


{
Session["name"] = TextBox1.Text;

SqlConnection coon = new SqlConnection("data source=AMAN-PC\\SQLEXPRESS;


initial catalog=session; integrated security=true;");
SqlCommand cmd = new SqlCommand("select session from s_table where name='" +
TextBox1.Text + "'", coon);

SqlDataReader rd;
rd = cmd.ExecuteReader();
if (rd.HasRows)
{
rd.Read();
Session["color"] = rd[0].ToString();
}

Response.Redirect("Default2.aspx");
}

Default2.aspx

<table width="90%" align="center">


<tr>
<td align="center" colspan="2">
<h1>SELECT BACKGROUND COLOR</h1>
</td>
</tr>
<tr>
<td align="center">
<asp:DropDownList runat="server" id="ColorSelector" autopostback="true"
onselectedindexchanged="ColorSelector_IndexChanged">
<asp:ListItem value="White" selected="True">Select color...</asp:ListItem>
<asp:ListItem value="Red">Red</asp:ListItem>
<asp:ListItem value="Green">Green</asp:ListItem>
<asp:ListItem value="Blue">Blue</asp:ListItem>
</asp:DropDownList>
&nbsp;<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Save" />
</td>
<td>
&nbsp;</td>
</tr>
</table>

Default2.aspx.cs

protected void Page_Load(object sender, EventArgs e)


{
BodyTag.Style["background-color"] = Session["color"].ToString();

protected void ColorSelector_IndexChanged(object sender, EventArgs e)


{
BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=AMAN-PC\\SQLEXPRESS;
initial catalog=session; integrated security=true;");
SqlCommand cmd = new SqlCommand("insert into ses_table
values('"+Session["name"].ToString()+"','"+ColorSelector.SelectedValue+"')", con);

cmd.ExecuteNonQuery();

}
protected void Button2_Click(object sender, EventArgs e)
{

Response.Redirect("Default.aspx");
}

Result
Q5. Make a WebSite which uses the Menu Control with the MultiView control on the
start page of your WebSite. Create the tabbed WebPages within the WebSite. Use
the Menu Control to display the tabs and the MultiView Control to display the
content that corresponds to the selected tab.

SOL: -

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Menu.aspx.cs"


Inherits="Menu"%>

<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Menu ID="Menu1" runat="server" BackColor="#B5C7DE"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#284E98" StaticSubMenuIndent="10px">
<Items>
<asp:MenuItem Text="Home" Value="Home">
<asp:MenuItem Text="AboutUs" Value="AboutUs"></asp:MenuItem>
<asp:MenuItem Text="ContactUs" Value="ContactUs"></asp:MenuItem>
<asp:MenuItem Text="OurServices" Value="OurServices"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Music" Value="Music">
<asp:MenuItem Text="Hindi" Value="Hindi"></asp:MenuItem>
<asp:MenuItem Text="Punjabi" Value="Punjabi"></asp:MenuItem>
</asp:MenuItem>
</Items>
<StaticSelectedStyle BackColor="#507CD1" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
<DynamicMenuStyle BackColor="#B5C7DE" />
<DynamicSelectedStyle BackColor="#507CD1" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#284E98" ForeColor="White" />
</asp:Menu>
<br />
<br />
<br />
<br />

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

Output:

Q6. Make a Website in which users are allowed to select the background colour
according to their preference. In future, whenever they visit the WebSite, the chosen
background colour must appear in the WebPage. In order to do so, use the concept
of Cookies to save the user’s preference.

SOL: -

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)

{
if (Session["BackgroundColor"] != null)
{
ColorSelector.SelectedValue = Session["BackgroundColor"].ToString();
BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
}
}

protected void ColorSelector_IndexChanged(object sender, EventArgs e)


{
BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
Session["BackgroundColor"] = ColorSelector.SelectedValue;

Label1.Text = Session.Timeout.ToString();
}
}

You might also like