Practical 3 A, B, C

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

PRACTICAL NO.

3 A

Aim: Create an a simple web page with various server controls to demonstrate setting and use of their properties .
(Example : AutoPostBack)

Code:

1] webForm1.aspx

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


Inherits="practicalno3A.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style3 {
width: 101px;
}
.auto-style6 {
width: 101px;
height: 24px;
}
.auto-style8 {
width: 101px;
height: 23px;
}
.auto-style9 {
width: 12px;
height: 24px;
}
.auto-style10 {
width: 12px;
}
.auto-style11 {
width: 12px;
height: 23px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td class="auto-style9">
<asp:Label ID="Label1" runat="server" Text="Roll No"></asp:Label>
</td>
<td class="auto-style6">
<asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style10">
<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>
</td>
<td class="auto-style3">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

</td>
</tr>
<tr>
<td class="auto-style10">
<asp:Label ID="Label3" runat="server" Text="Class"></asp:Label>
</td>
<td class="auto-style3">
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True" GroupName="class"
Text="FY" />
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True" GroupName="class"
Text="SY" />
<asp:RadioButton ID="RadioButton3" runat="server" AutoPostBack="True" GroupName="class"
Text="TY" />

</td>
</tr>
<tr>
<td class="auto-style11">
<asp:Label ID="Label4" runat="server" Text="Course"></asp:Label>
</td>
<td class="auto-style8">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>BSc.IT</asp:ListItem>
<asp:ListItem>BCOM</asp:ListItem>
<asp:ListItem>BA</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style11"></td>
<td class="auto-style8">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</td>
</tr>
<tr>
<td class="auto-style10">
<asp:Label ID="Label5" runat="server" Text="label"></asp:Label>
</td>
<td class="auto-style3">&nbsp;</td>
</tr>
</table>
<div>

</div>
</form>
</body>
</html>
2] webForm1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace practicalno3A
{
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 s;
if(RadioButton1.Checked==true)
{
s = RadioButton1.Text;
}
if (RadioButton2.Checked == true)
{
s = RadioButton2.Text;
}
else
{
s = RadioButton3.Text;
}
Label5.Text += "in " + s;

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{
Label5.Text = "You have been enrolled in " + " " + DropDownList1.SelectedItem;
}

}
}
PRACTICAL NO. 3 B

Aim : Demonstrate the use of calendar control to perform following operations.

(a) Display vacation in a calendar control

Code:

1] webForm1.aspx

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


Inherits="practical3BCalender.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:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="black


" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt" ForeColor="Black" Height="190px"
Width="350px" OnSelectionChanged="Calendar1_SelectionChanged" NextPrevFormat="FullMonth"
OnDayRender="Calendar1_DayRender" DayNameFormat="Short">
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True" Font-
Size="12pt" ForeColor="#333399" />
<TodayDayStyle BackColor="#CCCCCC" />
</asp:Calendar>

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

2] webForm1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace practical3BCalender
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Calendar1_SelectionChanged(object sender, EventArgs e)


{

}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{

//displaying vacations betweens the dates

Calendar1.Caption = "UES Calendar";


if (e.Day.Date.Day == 30 && e.Day.Date.Month == 10)
{
Calendar1.SelectedDate = new DateTime(2024, 10, 29);
Calendar1.SelectedDates.SelectRange(Calendar1.SelectedDate, Calendar1.SelectedDate.AddDays(13));
Label lb = new Label();
lb.Text = "<br/>Diwali Vacation";
e.Cell.Controls.Add(lb);
}

}
}
PRACTICAL NO. 3 C

Aim : Demonstrate the use of TreeView control perform following operations

(a) TreeView Operations

Code:

1]WebForm1.aspx :

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


Inherits="practical3CtreeViewOperation.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:TreeView ID="TreeView1" runat="server"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged"
OnTreeNodeCollapsed="TreeView1_TreeNodeCollapsed">
<Nodes>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="Courses" Value="Courses">
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="BSc.IT" Value="BSc.IT">
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="FYIT"
Value="FYIT"></asp:TreeNode>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="SYIT"
Value="SYIT"></asp:TreeNode>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="TYIT"
Value="TYIT"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="BCOM" Value="BCOM">
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="FYBCOM"
Value="FYBCOM"></asp:TreeNode>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="SYBCOM"
Value="SYBCOM"></asp:TreeNode>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="TYBCOM"
Value="TYBCOM"></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</div>
</form>
</body>
</html>
2] WebForm1.aspx.cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace practical3CtreeViewOperation
{
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);
}
protected void TreeView1_TreeNodeCollapsed(object sender,TreeNodeEventArgs e)
{
Response.Write("The Value Collapsed Was : " + e.Node.Value);
}
}
}

You might also like