0% found this document useful (0 votes)
17 views5 pages

Awp (5a & 5B)

Advance web programming practical Notes Tybsc it

Uploaded by

ptemp389
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)
17 views5 pages

Awp (5a & 5B)

Advance web programming practical Notes Tybsc it

Uploaded by

ptemp389
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/ 5

Practical No: 5

A) Create Web Form to demonstrate use User Controls.

Code:
Footer.ascx Page:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Footer.ascx.cs"
Inherits="Footer" %>
<table style="width: 100%;">
<tr>
<td align="center" style="font-family: Cambria; color: #FF0000;
font-weight: bold; text-decoration: blink; font-size: large; background-
color: #00CCFF;">
<asp:Label ID="Label1" runat="server" Text="Advance Web Programming
Practical Session"></asp:Label>
</td>
</tr>
</table>

Default.aspx Page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<%@ Register Src="~/Footer.ascx" TagName="footer" TagPrefix="AWPfooter" %>
<!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:Label ID="Label1" runat="server" Text="Welcome to TYIT Classroom."
Font-Bold="True" Font-Italic="True" Font-Size="XX-Large"></asp:Label>
<br /> <br /> <br />
</div>
<AWPfooter:footer ID="footer1" runat="server" />
</form>
</body>
</html>

Output:
B) View State:
ViewState is an important client side state management technique. ViewState is
used to store user data on page at the
time of post back of web page. ViewState does not hold the controls, it holds the
values of controls. It does not restore
the value to control after page post back. ViewState can hold the value on single
web page, if we go to other page
using response.redirect then ViewState will be null.

Code:
Default.aspx Page:
<%@ 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 align="center">
<table style="border: medium solid #000000; height: 270px;" border="0"
frame="border">
<tr>
<td align="center" bgcolor="#009933" colspan="2">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-
Names="Century Schoolbook" Font-Size="XX-Large"
ForeColor="White" Text="View State Example"></asp:Label>
</td>
</tr>
<tr>
<td align="right" width="50%">
<asp:Label ID="Label2" runat="server" Text="Enter Value:" Font-
Bold="True" Font-Italic="False" Font-Names="Century Schoolbook"
Font-Size="X-Large"></asp:Label>
</td>
<td align="left">
<asp:TextBox ID="TextBox1" runat="server" Font-Size="X-Large">
</asp:TextBox>
</td>
</tr>
<tr>
<td width="50%" align="center">
<asp:Button ID="Button1" runat="server" Text="Clear Value" Font-
Bold="True" Font-Names="Times New Roman" Font-Size="X-Large"
onclick="Button1_Click" />
</td>
<td align="center">
<asp:Button ID="Button2" runat="server" Text="Display Value"
Font-Bold="True" Font-Names="Times New Roman" Font-Size="X-
Large" onclick="Button2_Click" />
</td>
</tr><tr>
<td colspan="2" align="center">
<asp:Label ID="Label3" runat="server" Font-Size="X-Large"
Font-Strikeout="False"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Default.aspx.cs Page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["name"] = TextBox1.Text;
TextBox1.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
Label3.Text = ViewState["name"].ToString();
}
}

Output:
After entering value in Textbox, click on “CLEAR VALUE” Button then click on “Display
Value” Button”.

You might also like