AWP Practical 3-1
AWP Practical 3-1
NETWITHC#
IT-7152
2018-2019
a) Create a simple web page with various sever controls to demonstrate setting and use
of their properties. (Example : AutoPostBack)
GUI:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width:100%;
}
.style2
{
width:153px;
}
.style3
{
width:153px;
height:26px;
}
.style4
{
height:26px;
}
.auto-style1 {
width: 153px;
height: 28px;
}
Page 1
T.Y.B.SC. (I.T.) - ASP.NETWITHC#
IT-7152
2018-2019
.auto-style2 {
height: 28px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td class="style2">
<asp:Label ID="Label1" runat="server" Text="Roll No">
</asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label2" runat="server" Text="Name">
</asp:Label></td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
Class</td>
<td class="auto-style2">
<asp:RadioButton ID="RadioButton1" runat="server" Text="FY"/>
<asp:RadioButton ID="RadioButton2" runat="server" Text="SY"/>
<asp:RadioButton ID="RadioButton3" runat="server" Text="TY"/>
</td>
</tr>
<tr>
<td class="style3">
<asp:Label ID="Label4" runat="server" Text="Course"></asp:Label>
</td>
<td class="style4">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>B.Com</asp:ListItem>
<asp:ListItem>BMS</asp:ListItem>
<asp:ListItem>B.SC(IT)</asp:ListItem>
<asp:ListItem>B.Sc(CS)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style3">
</td>
<td class="style4">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button"/>
</td>
</tr>
</table>
</div>
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
</form>
</body>
Page 2
T.Y.B.SC. (I.T.) - ASP.NETWITHC#
IT-7152
2018-2019
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string s;
if (RadioButton1.Checked == true)
{
s = RadioButton1.Text;
}
else if (RadioButton2.Checked == true)
{
s = RadioButton1.Text;
}
else
{
s = RadioButton3.Text;
}
Label5.Text = "You have been enrolled in " + DropDownList1.SelectedItem;
Label5.Text += " in " + s;
}
}
}
Output:-
Page 3
T.Y.B.SC. (I.T.) - ASP.NETWITHC#
IT-7152
2018-2019
c) Selected day in a calendar control using style d) Difference between two calendar dates
GUI:-
Page 4
T.Y.B.SC. (I.T.) - ASP.NETWITHC#
IT-7152
2018-2019
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Page 5
T.Y.B.SC. (I.T.) - ASP.NETWITHC#
IT-7152
2018-2019
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplicationsDiv2
{
public partial class CalenderControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lbldates.Text = "You Selected these Dates:<br>";
foreach (DateTime dt in Calendar1.SelectedDates)
{
lbldates.Text += dt.ToShortDateString() + "<br/>";
}
}
Page 6
T.Y.B.SC. (I.T.) - ASP.NETWITHC#
IT-7152
2018-2019
Calendar1.TitleFormat = TitleFormat.Month;
Label5.Text = "Todays Date " + Calendar1.TodaysDate.ToShortDateString();
Label2.Text = "Ganpati Vacation Starts: 9-13-2018";
TimeSpan d = new DateTime(2018, 9, 13) - DateTime.Now;
Label3.Text = "Days Remaining for Ganpati Vacation: " + d.Days.ToString();
if (Calendar1.SelectedDate.ToShortDateString() == "9-13-2018")
{
Label4.Text = "<b>Ganpati Festival Starts</b>";
}
if (Calendar1.SelectedDate.ToShortDateString() == "9-23-2018")
{
Label4.Text = "<b>Ganpati Festival Starts</b>";
}
}
protected void Calender1_SelectionChanged(object Sender, EventArgs e)
{
Label4.Text = "You Selected Date=
"+Calendar1.SelectedDate.Date.ToString();
}
protected void Calender1_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
{
if (e.Day.Date.Day == 5 && e.Day.Date.Month == 9)
{
e.Cell.BackColor = System.Drawing.Color.Red;
Label lbl = new Label();
lbl.Text = "<b>Teachers day</b>";
e.Cell.Controls.Add(lbl);
Image g1 = new Image();
g1.ImageUrl="Images/Desert.jpg";
g1.Height=20;
g1.Width=20;
e.Cell.Controls.Add(g1);
}
if (e.Day.Date.Day == 13 && e.Day.Date.Month == 9)
{
Calendar1.SelectedDate = new DateTime(2018, 9, 12);
Calendar1.SelectedDates.SelectRange(Calendar1.SelectedDate,
Calendar1.SelectedDate.AddDays(10));
Label lbl1 = new Label();
lbl1.Text = "<br>Ganpati";
e.Cell.Controls.Add(lbl1);
}
}
}
}
Output:-
Page 7
T.Y.B.SC. (I.T.) - ASP.NETWITHC#
IT-7152
2018-2019
Page 8