2. Set the Calendar control's properties like Title, SelectedDate etc. 3. Handle the Calendar control's SelectionChanged event to display the selected date: protected void Calendar1_SelectionChanged(object sender, EventArgs e) { lblSelectedDate.Text = Calendar1.SelectedDate.ToShortDateString(); } 4. Add a button and handle its click event to programmatically select a date: protected void"> 2. Set the Calendar control's properties like Title, SelectedDate etc. 3. Handle the Calendar control's SelectionChanged event to display the selected date: protected void Calendar1_SelectionChanged(object sender, EventArgs e) { lblSelectedDate.Text = Calendar1.SelectedDate.ToShortDateString(); } 4. Add a button and handle its click event to programmatically select a date: protected void">
Awp Practical 4,5,6,7
Awp Practical 4,5,6,7
Awp Practical 4,5,6,7
Practical 4
Practical 4-A
4a - Create simple application to demonstrate use of Delegates and events.
Delegatesandevents.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DelegatesAndEvents.aspx.cs"
Inherits="DelegatesAndEvents" %>
<!DOCTYPE html>
<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>
Delegatesandevents.aspx.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
lblResult2.Text = d2();
}
2
Design
Output
23-9-2020
3
Practical 4-B
4b - Create simple application to demonstrate use of Exception handling.
ExceptionHandling.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Exception Handling.aspx.cs"
Inherits="Exception_Handling" %>
<!DOCTYPE html>
<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>
ExceptionHandling.aspx.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
4
}
}
}
5
Design
Output
23-9-2020
Practical 4-C
6
4c - Create simple application to demonstrate use of Hierarchical Inheritance.
HierarchicalInheritance.aspx file
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
HIERARCHIACAL INHERITANCE<br />
<br />
Enter a :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
Enter b :
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnResult" runat="server" Text="Calculate" />
<br />
<br />
a + b = <asp:Label ID="Label1" runat="server"></asp:Label>
<br />
<br />
a-b=
<asp:Label ID="Label2" runat="server"></asp:Label>
</form>
</body>
</html>
HierarchicalInheritance.aspx.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
C c = new C();
int m = Convert.ToInt32(TextBox1.Text);
int n = Convert.ToInt32(TextBox2.Text);
Label1.Text = x.ToString();
Label2.Text = y.ToString();
}
public class A
{
publicint a;
publicint b;
}
public class B : A
{
publicint add(int x, int y)
{
a = x;
b = y;
return a + b;
}
}
public class C : A
{
publicint sub(int x, int y)
{
a = x;
b = y;
return a - b;
}
}
8
Design
Output
23-9-2020
Practical 4-D
4d - Create simple application to demonstrate use of Multilevel Inheritance.
MultilevelInheritance.aspx file
9
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Multilevel Inheritance.aspx.cs"
Inherits="Multilevel_Inheritance" %>
<!DOCTYPE html>
<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>
MultilevelInheritance.aspx.cs
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
Label2.Text = x.ToString();
Label3.Text = y.ToString();
Label4.Text = z.ToString();
}
}
public class A
{
publicint pow2(intval)
{
returnval * val;
}
}
public class B : A
{
publicint pow3(intval)
{
int v = pow2(val);
return v * val;
}
}
public class C : B
{
publicint pow4(intval)
{
int v = pow3(val);
return v * val;
}
}
Design
11
Output
23-9-2020
Practical 4-E
4e - Create simple application to demonstrate use of Single Inheritance.
SingleInheritance.aspx file
12
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Single Inheritance.aspx.cs"
Inherits="Single_Inheritance" %>
<!DOCTYPE html>
<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>
SingleInheritance.aspx.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
13
int x = b.sqr(n);
int y = b.cube(n);
lblSquare.Text = x.ToString();
lblCube.Text = y.ToString();
}
}
public class A
{
publicintsqr(intval)
{
returnval * val;
}
}
Design
14
Output
14-10-2020
Practical 5
Practical 5-A
15
5a - Demonstrate the use of Calendar control to perform following operations.
i) Demonstrate the use of Calendar control to
perform following operations. Display
messages in a calendar control.
ii) Display vacation in a calendar control.
iii) Selected day in a calendar control using
style.
iv) Difference between two calendar dates.
CalendarControl.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calendar Control.aspx.cs" Inherits="Calendar_Control"
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
</div>
</form>
</body>
</html>
CalendarControl.aspx.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday;
Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth;
Calendar1.TitleFormat = TitleFormat.Month;
if (Calendar1.SelectedDate.ToShortDateString() == "12-24-2020")
17
Label3.Text = "<b>CHRISTMAS VACATION STARTS</b>";
if (Calendar1.SelectedDate.ToShortDateString() == "12-02-2021")
Label3.Text = "<b>CHRISTMAS VACATION ENDS</b>";
}
Design
18
Output
19
20
14-10-2020
Practical 5-B
5b - Create a simple web page with various sever controls to demonstrate
setting and use of their properties.
StudentProfile.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="StudentProfile.aspx.cs" Inherits="StudentProfile" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
StudentProfile.aspx.cs
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
22
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
if (ViewState["name"] == null)
{
ViewState["name"] = str;
}} // Response.Redirect("https://mail.google.com/mail/u/0/#inbox");
}
protected void Button1_Click(object sender, EventArgs e)
{
lblViewState.Text = ViewState["name"].ToString();
}
protected void btnAdd_Click(object sender, EventArgs e)
{
// txtLanguage.Text = "";
for (inti = 0; i<lstLanguage.Items.Count; i++)
{
if (lstLanguage.Items[i].Selected == true)
{
txtLanguage.Text = txtLanguage.Text + " " + lstLanguage.Items[i].Text + "\n";
}
}}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Font.Size = int.Parse(DropDownList1.SelectedItem.Text);
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = DropDownList2.SelectedItem.Text;
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
Label1.BackColor = System.Drawing.Color.Red;
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
Label1.BackColor = System.Drawing.Color.Blue;
}
protected void RadioButton3_CheckedChanged(object sender, EventArgs e)
{
Label1.BackColor = System.Drawing.Color.Beige;
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
Label1.Font.Bold = true;
23
}
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
Label1.Font.Italic = true;
}
protected void CheckBox3_CheckedChanged(object sender, EventArgs e)
{
Label1.Font.Underline = true;
}}
24
Design
Output
25
21-10-2020
26
Practical 6
Practical 6-A
6 a - Demonstrate the use of Treeview control and Data list control
StudentDetail.xml file
27
Tree Control
TreeControl.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TreeControl.aspx.cs" Inherits="TreeControl" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
TREE CONTROL NAVIGATION :
Treeview control navigation:<asp:TreeView ID="TreeView1" runat="server" Width="150px" ImageSet="Arrows"
BackColor="#FF66FF" BorderColor="#333399" ForeColor="#009900">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<Nodes>
<asp:TreeNode Text="ASP.NET Practs" Value="New Node">
<asp:TreeNode Text="Calendar Control" Value="RED" NavigateUrl="~/calndrCtrl.aspx"
Target="_blank"></asp:TreeNode>
<asp:TreeNode Text="Constructor Overloading" Value="GREEN" NavigateUrl="~/clsconstrc.aspx"></asp:TreeNode>
<asp:TreeNodeNavigateUrl="~/singleInh.aspx" Text="Inheritance" Value="BLUE"></asp:TreeNode>
<asp:TreeNodeNavigateUrl="~/clsProp.aspx" Text="Class Properties" Value="Class Properties"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<RootNodeStyleBackColor="#00FF99" BorderColor="#006600" BorderStyle="Ridge" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px"
BackColor="#CCFFFF" BorderColor="#990033" BorderStyle="Double" Font-Bold="True" Font-Italic="True" />
</asp:TreeView>
<br />
<asp:TreeView ID="TreeView2" runat="server" ImageSet="Arrows" ShowLines="True">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<Nodes>
<asp:TreeNode Text="HOME" Value="HOME"></asp:TreeNode>
<asp:TreeNodeNavigateUrl="https://www.amazon.com/" Target="_blank" Text="EMPLOYEE" Value="EMPLOYEE">
<asp:TreeNode Text="UPLOAD RESUME" Value="UPLOAD RESUME"></asp:TreeNode>
<asp:TreeNode Text="EDIT RESUME" Value="EDIT RESUME"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="ADMIN" Value="ADMIN">
<asp:TreeNode Text="ADD USER" Value="ADD USER"></asp:TreeNode>
<asp:TreeNode Text="DELETE USER" Value="DELETE USER"></asp:TreeNode>
<asp:TreeNode Text="UPDATE USER" Value="UPDATE USER"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="EMPLOYER" Value="EMPLOYER">
<asp:TreeNode Text="UPLOAD JOB PROFILE" Value="UPLOAD JOB PROFILE"></asp:TreeNode>
<asp:TreeNode Text="UPDATE JOB PROFILE" Value="UPDATE JOB PROFILE"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
28
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>
<br />
<br />
<br />
Fetch Datalist Using XML data :
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<table border="1" class="table">
<tr>
<td>Roll Number : <%# Eval("sid") %><br />
Name of the student : <%# Eval("sname") %><br />
Class : <%# Eval("sclass")%></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<br />
<asp:DataList ID="DataList2" runat="server">
<ItemTemplate>
<table border="1">
</table>
</ItemTemplate>
</asp:DataList>
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
TreeControl.aspx.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Data;
public partial class TreeControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
29
protected void BindData()
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("Studentdetail.xml"));
30
Design
31
Output
32
After Clicking on Employee it will take you to the Amazon link
21-10-2020
33
Practical 7
Practical 7-A
a) Create Web Form to demonstrate use of Web User Control.
WebUserControl.aspx file
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title></title>
</head>
<body>
<form id=”form1”runat=”server”>
<div>
<uc:Student ID=”studentcontrol”runat=”server” />
</div>
</form>
</body>
</html>
WebUserControl.aspx.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
}
}
MyWebUserControl.ascx file
34
<%@ Control Language=”C#”AutoEventWireup=”true”CodeFile=”MyWebUserControl.ascx.cs”
Inherits=”MyWebUserControl” %>
<h3>This is User Contro1 </h3>
<table>
<tr>
<td>Name</td>
<td>
<asp:TextBox ID=”txtName”runat=”server”></asp:TextBox>
</td>
</tr>
<tr>
<td>City</td>
<td>
<asp:TextBox ID=”txtcity”runat=”server”></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID=”txtSave”runat=”server” Text=”Save” style=”height: 26px” />
</td>
</tr>
</table>
<br />
<asp:Label ID=”Label1”runat=”server”ForeColor=”black” Text=”“></asp:Label>
MyWebUserControl.ascx.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
35
Default.aspx file
<%@ Page Language=”C#”AutoEventWireup=”true”CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html>
<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>
Default.cs file
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
}
}
36
Design
Output
Shirin Husain
Shirin Husain
37