You are on page 1of 5

Practical no: 3(a)

Create a simple webpage with various server controls to demonstrate setting and use of their
properties (Example: AutoPostBack)

Solution:

wbForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

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

protected void Button1_Click(object sender, EventArgs e)


{
Panel1.BackColor = Color.FromName(DropDownList1.SelectedItem.Text);
Panel1.Font.Size = Convert.ToInt32(TextBox1.Text);
Panel1.Font.Name = DropDownList2.SelectedItem.Text;
if (CheckBox1.Checked)
{
Image1.Visible = true;
}
else
{
Image1.Visible = false;
}
Label1.Visible = true;
Label1.Text = TextBox2.Text;
}
}
}
Output:

Practical no: 3(b)


Demonstrate the use of calendar control to perform following operations:
1- Display messages in a calendar control
2- Display vacation in a calendar control
3- Selected day in a calendar control using style
4- Difference between two calendar dates.

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

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

protected void Button1_Click(object sender, EventArgs e)


{
Label2.Text = "" + Calendar1.TodaysDate.ToShortDateString();
Label2.Visible = true;
Label3.Text = "09-13-2018";
Label3.Visible = true;
TimeSpan d = new DateTime(2018, 9, 13) - DateTime.Now;
Label4.Text = "" + d.ToString();
Label4.Visible = true;
TimeSpan d1 = new DateTime(2018, 12, 31) - DateTime.Now;
Label5.Text = "" + d1.ToString();
Label5.Visible = true;
}

protected void Calendar1_SelectionChanged(object sender, EventArgs e)


{
Label1.Text = "" + Calendar1.SelectedDate.Date.ToShortDateString();
Label1.Visible = true;
}

protected void Button2_Click(object sender, EventArgs e)


{
Label1.Text = "";
Label2.Text = "";
Label3.Text = "";
Label4.Text = "";
Label5.Text = "";
}
}
}

Output:
Practical no: 4(b)
Create Web Form to demonstrate use of AdRotater Control.

Solution:
XML file:

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


<Advertisements>
<Ad>
<ImageUrl>asus-zenfone-5z-5.jpg</ImageUrl>
<Keyword>phones, smartphones</Keyword>
<NavigateUrl>https://www.youtube.com/watch?v=GuuQnENs0HE</NavigateUrl>
<Impression>2</Impression>
</Ad>
<Ad>
<ImageUrl>evtwgjgb3xbmtirbyawn.jpg</ImageUrl>
<Keyword> phones, smartphones </Keyword>
<NavigateUrl>https://www.youtube.com/watch?v=GuuQnENs0HE</NavigateUrl>
<Impression>2</Impression>
</Ad>
<Ad>
<ImageUrl>V30-medium01.jpg</ImageUrl>
<Keyword> phones, smartphones </Keyword>
<NavigateUrl>https://www.youtube.com/watch?v=GuuQnENs0HE</NavigateUrl>
<Impression>2</Impression>
</Ad>
</Advertisements>
Aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Adrotater.aspx.cs"
Inherits="Adrotater.Adrotater" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/XMLFile1.xml"></asp:XmlDataSource>
</form>
</body>
</html>

Output:

You might also like