0% found this document useful (0 votes)
130 views68 pages

Certificate: Smt. Sushiladevi Deshmukh College of Arts, SCIENCE AND COMMERCE, Airoli, Navi Mumbai - 400 708

The document is a certificate for a student named Sudarshan Date who completed practical work in the subject "ASP dot Net with C#" as a partial requirement to earn a Bachelor of Science in Information Technology degree from the University of Mumbai. The certificate details the student's enrollment number, the internal and external guides who supervised the practical work, and is signed by the principal with the college seal. The attached index lists 10 practical works completed by the student related to C#, ASP.NET, web forms, controls, navigation, databases, and AJX with code examples.

Uploaded by

Sudarshan Date
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views68 pages

Certificate: Smt. Sushiladevi Deshmukh College of Arts, SCIENCE AND COMMERCE, Airoli, Navi Mumbai - 400 708

The document is a certificate for a student named Sudarshan Date who completed practical work in the subject "ASP dot Net with C#" as a partial requirement to earn a Bachelor of Science in Information Technology degree from the University of Mumbai. The certificate details the student's enrollment number, the internal and external guides who supervised the practical work, and is signed by the principal with the college seal. The attached index lists 10 practical works completed by the student related to C#, ASP.NET, web forms, controls, navigation, databases, and AJX with code examples.

Uploaded by

Sudarshan Date
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 68

TYBSc(IT)

SMT. SUSHILADEVI DESHMUKH COLLEGE OF ARTS,


SCIENCE AND COMMERCE , Airoli, Navi Mumbai – 400 708

Date :

Certificate
This is to certify that Mr. / _Sudarshan Date

seat no of B.Sc. IT Semester V has completed the practical work in the subject of

“ASP dot Net with C#” during the academic year 2018 – 19 under the guidance of Prof. Dr. Prakash

Naik. being the partial requirement for the fulfillment of the curriculum of Degree of Bachelor of Science

in Information Technology, University of Mumbai.

Signature of Internal Guide Signature of HOD

Signature of External
Principal

College Seal

Roll No.: 08 Name :Sudarshan Date Page 1


TYBSc(IT)

INDEX
Sr List of Practical Date Signature
No.

1 Working with basic C# and ASP .NET / /2018


a. Create an application that obtains four int values from the / /2018
user and displays the product.

b. Create an application to demonstrate string operations. / /2018


c. Create an application that receives the (Student Id, Student / /2018
Name, Course Name, Date of Birth) information from a set
of students. The application should also display the
information of all the students once the data entered.

Create an application to demonstrate following operations / /2018

i. Generate Fibonacci series.ii. Test for prime numbers.

iii. Test for vowels.iv. Use of foreach loop with arrays

v. Reverse a number and find sum of digits of a number.


2 Working with Object Oriented C# and ASP .NET / /2018
a. Create simple application to perform following operations / /2018
i. Finding factorial Valueii. Money Conversion

b. Create simple application to demonstrate use of following / /2018


concepts
i. Function Overloading ii. Inheritance (all types)

iii. Constructor overloading iv. Interfaces

c. Create simple application to demonstrate use of following / /2018


concepts i. Using Delegates and events

3 Working with Web Forms and Controls / /2018


Demonstrate the use of Treeview control perform / /2018
following operations. a) Treeview control

4 Working with Form Controls / /2018


Create a Registration form to demonstrate use of various / /2018
Validation controls

Roll No.: 08 Name :Sudarshan Date Page 2


TYBSc(IT)

5 Working with Navigation, Beautification and Master page / /2018


a. Create Web Form to demonstrate use of Website / /2018
Navigation controls and Site Map.

b. Create a web application to demonstrate use of Master / /2018


Page with applying Styles and Themes for page
beautification.
6 Working with Database / /2018
Demonstrate the use USE OF GridView, DetailsView, / /2018
ListView CONTROLS.

7 Working with Database / /2018


a,b a. Create a web application to display Databinding using / /2018
dropdownlist control. OR
b. Create a web application for to display the phone no of
an author using database.

c Create a web application for inserting and deleting record / /2018


from a database. (Using Execute-Non Query).

8 Working with data controls / /2018


Create a web application to display Using Disconnected / /2018
Data Access and Databinding using GridView.

9 Working with GridView control / /2018


a,b a. Create a web application to demonstrate use of / /2018
GridView button column and GridView events.
AND
b. Create a web application to demonstrate GridView
paging and Creating own table format using
GridView.

10 Working with AJAX and XML / /2018


I).SCRIPTMANAGERCONTROL / /2018
II).TIMER CONTROL
III).UPDATEPANEL CONTROL
IV).UPDATEPROGRESS CONTROL

Roll No.: 08 Name :Sudarshan Date Page 3


TYBSc(IT)

1. SIMPLE PROGRAMS WITH C#:


a) Write a console application that obtain four int values from user and display the product.
Product.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="product.aspx.cs"Inherits="product"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0
Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
.style1
{
font-size: x-large;
}
</style>
</head>
<bodystyle="font-weight: 700">
<formid="form1"runat="server">
<div>
<br/>
<spanclass="style1">PRODUCT OF FOUR NUMBER</span><br/>
<br/>
<br/>
Enter First Number :&nbsp;
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<br/>
<br/>
Enter Second Number :
<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>
<br/>
<br/>
Enter Third Number :
<asp:TextBoxID="TextBox3"runat="server"></asp:TextBox>
<br/>
<br/>
Enter Fourth Number :
<asp:TextBoxID="TextBox4"runat="server"></asp:TextBox>
<br/>
<br/>
<asp:ButtonID="Button1"runat="server"Height="35px"onclick="Button1_Click"
style="font-weight: 700"Text="Find Product"Width="98px"/>
<br/>
<br/>
<asp:LabelID="Label1"runat="server"
style="font-size: x-large; color: #00FF00"Text="Label"></asp:Label>
<br/>
</div>
</form>
</body>
</html>
Product.aspx.cs

Roll No.: 08 Name :Sudarshan Date Page 4


TYBSc(IT)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
publicpartialclassproduct : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
int a, b, c, d, f;
a = int.Parse(TextBox1.Text);
b = int.Parse(TextBox2.Text);
c = int.Parse(TextBox3.Text);
d = int.Parse(TextBox4.Text);
f = a * b * c * d;
Label1.Text = "The Product is = " + f;
}
}

Roll No.: 08 Name :Sudarshan Date Page 5


TYBSc(IT)

b. Create an application to demonstrate string operations.


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace stringoperator
{
class Program
{
static void Main(string[] args)
{
string[] myWords;
start:
string myString;
char[] separator={' '};
Console.WriteLine("Type any string Please");
myString=Console.ReadLine();
myWords=myString.Split(separator);
foreach (string word in myWords)
{
Console.Write("\"{0}\"", word);
}
Console.ReadKey();
Console.WriteLine();
Console.Clear();
goto start;

}
}
}

Output:

Roll No.: 08 Name :Sudarshan Date Page 6


TYBSc(IT)

c. Create an application that receives the (Student Id, Student Name, Course Name, Date of Birth)
information from a set of students. The application should also display the information of all the
students once the data entered.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace studentdetail
{
class Program
{
public struct Student
{
public int stud_id;
public string stud_name, course_name, stud_dob;
}
static void Main(string[] args)
{
Student[] ob1 = new Student[3];
int a;
for (a = 0; a < 3; a++)
{
Console.WriteLine("Enter Student id = ");
ob1[a].stud_id = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Student Name = ");
ob1[a].stud_name = Console.ReadLine();
Console.WriteLine("Enter Student Course name = ");
ob1[a].course_name = Console.ReadLine();
Console.WriteLine("Enter Student date of birth = ");
ob1[a].stud_dob = Console.ReadLine();
}
Console.WriteLine("\t\t\t\t\tSTUDENT INFORMATION");
Console.WriteLine("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*-*-*");
Console.WriteLine("|\t Student id\t|\tStudent Name\t|\tCourse Name\t|\tStudent DOB\t|");
Console.WriteLine("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*-*-*");
for (a = 0; a < 3; a++)
{
Console.WriteLine("|\t\t" + ob1[a].stud_id + "\t|\t" + ob1[a].stud_name + "\t|\t" +
ob1[a].course_name + "\t\t|\t" + ob1[a].stud_dob + "\t|");

}
Console.WriteLine("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*-*-*-*");
Console.ReadKey();
}
}
}

Roll No.: 08 Name :Sudarshan Date Page 7


TYBSc(IT)

Roll No.: 08 Name :Sudarshan Date Page 8


TYBSc(IT)

Create an application to demonstrate following operations


i. Generate Fibonacci series.

Fibonacci.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="string3.aspx.cs"Inherits="string3"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
.style1
{
font-size: x-large;
}
.style2
{
font-size: large;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>

<br/>
strong><spanclass="style1">FIBONACCI SERIES</span><br/>
<br/>
<spanclass="style2">&nbsp;Enter Number :</span></strong>&nbsp;
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<br/>
<br/>
<asp:ButtonID="Button1"runat="server"onclick="Button1_Click"
style="font-weight: 700"Text="SUBMIT"/>
<br/>
<br/>
<br/>
<asp:ListBoxID="ListBox1"runat="server"Height="283px"
style="font-weight: 700; color: #00FF00; font-size: large"Width="120px">
</asp:ListBox>

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

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

publicpartialclassstring3 : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{

Roll No.: 08 Name :Sudarshan Date Page 9


TYBSc(IT)

}
protectedvoid Button1_Click(object sender, EventArgs e)
{
int n;
n = int.Parse(TextBox1.Text);
int a = 0;
int b = 1;
for (int i = 0; i < n; i++)
{
int temp = a;
a = b;
b = temp + b;
ListBox1.Items.Add("" + a);
}

}
}

Roll No.: 08 Name :Sudarshan Date Page 10


TYBSc(IT)

ii) Test for prime numbers.

Prime.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="prime.aspx.cs"Inherits="prime"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title></title>
<styletype="text/css">
.style1
{
font-size: x-large;
}
.style2
{
font-size: large;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>
<br/>
<spanclass="style1">&nbsp;</span><strong><spanclass="style1">CHECK PRIME
NUMBER</span><br/>
<spanclass="style2">&nbsp;Enter Number :</span></strong>&nbsp;
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<br/>
<br/>
<asp:ButtonID="Button1"runat="server"onclick="Button1_Click"
style="font-weight: 700"Text="SUBMIT"/>
<br/>
<br/>
<asp:ListBoxID="ListBox1"runat="server"Height="94px"
style="font-weight: 700; color: #00FF00; font-size: large"Width="120px">
</asp:ListBox>
</div>
</form>
</body>
</html>

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

publicpartialclassprime : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
int flag = 0;
int x;
x = int.Parse(TextBox1.Text);
bool r;

Roll No.: 08 Name :Sudarshan Date Page 11


TYBSc(IT)

for (int i = 2; i < x; i++)


{
if (x % i == 0)
{
flag = 1;
break;
}
else
{
flag = 0;
}
}
if (flag == 0)
r = true;
else
r = false;
ListBox1.Items.Add(""+r);

}
}

Roll No.: 08 Name :Sudarshan Date Page 12


TYBSc(IT)

iii. Test for vowels.


Vowel.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="vowel.aspx.cs"Inherits="vowel"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title></title>
<styletype="text/css">
.style1
{
font-size: x-large;
}
.style2
{
font-size: large;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>
<strong><spanclass="style1">CHECK VOWEL
CHARECTER</span><br/>
<spanclass="style2">&nbsp;Enter Charecter :</span></strong>&nbsp;
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<br/>
<asp:ButtonID="Button1"runat="server"onclick="Button1_Click"
style="font-weight: 700"Text="SUBMIT"/>
<br/>
<asp:ListBoxID="ListBox1"runat="server"Height="94px"
style="font-weight: 700; color: #00FF00; font-size: large"Width="411px">
</asp:ListBox>

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

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

publicpartialclassvowel : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{

}
protectedvoid Button1_Click(object sender, EventArgs e)
{
char c;
c = char.Parse(TextBox1.Text);
switch (c)
{
case'a':

Roll No.: 08 Name :Sudarshan Date Page 13


TYBSc(IT)

case'e':
case'i':
case'o':
case'u':
case'A':
case'E':
case'I':
case'O':
case'U': ListBox1.Items.Add("'" + c + "' Is A Vowel...!!!");
break;

default: ListBox1.Items.Add("'" + c + "' Is A Consonents...!!!");


break;
}

}
}

Roll No.: 08 Name :Sudarshan Date Page 14


TYBSc(IT)

iv. Use of foreach loop with arrays


foreach.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="foreach1.aspx.cs"Inherits="foreach1"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title></title>
<styletype="text/css">
.style1 { font-size: x-large; }
</style>
</head>
<body>
<formid="form1"runat="server">
<div>
<spanclass="style1">&nbsp;</span><strong><spanclass="style1">FOREACH LOOP WITH
ARRAY</span><br/>
</strong>
<asp:ListBoxID="ListBox1"runat="server"Height="181px"
style="font-weight: 700; color: #00FF00; font-size: large"Width="177px">
</asp:ListBox>
</div>
</form>
</body>
</html>

foreach.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
publicpartialclassforeach1 : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
int[] myArray = { 24, 25, 26, 27,28};
foreach (int m in myArray)
{
ListBox1.Items.Add(" " + m);
}
}
}

Roll No.: 08 Name :Sudarshan Date Page 15


TYBSc(IT)

v. Reverse a number and find sum of digits of a number.


Reverse.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="reverse.aspx.cs"Inherits="reverse"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title></title>
<styletype="text/css">
.style1
{
font-size: x-large;
}
.style2
{
font-size: large;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>
strong><spanclass="style1"> REVERSE
NUMBER</span><br/>
<spanclass="style2">&nbsp;Enter Number :</span></strong>&nbsp;
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<br/>
<asp:ButtonID="Button1"runat="server"onclick="Button1_Click"
style="font-weight: 700"Text="SUBMIT"/>
<br/>
<asp:ListBoxID="ListBox1"runat="server"Height="94px"
style="font-weight: 700; color: #00FF00; font-size: large"Width="411px">
</asp:ListBox>

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

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

publicpartialclassreverse : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{

}
protectedvoid Button1_Click(object sender, EventArgs e)
{
int num = int.Parse(TextBox1.Text);
int rev = 0, temp = 0, sum = 0;
while (num > 0)
{
temp = num % 10;

Roll No.: 08 Name :Sudarshan Date Page 16


TYBSc(IT)

rev = rev * 10 + temp;


num = num / 10;
sum = sum + temp;
}
ListBox1.Items.Add("Reverse Number Is: " + rev);
ListBox1.Items.Add("Sum Of The Digits Is: " + sum);

}
}

Roll No.: 08 Name :Sudarshan Date Page 17


TYBSc(IT)

2. Working with Object Oriented C# and ASP .NET


a. Create simple application to perform following operations
i. Finding factorial Value
Factorial.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="factorial.aspx.cs"Inherits="factorial"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title></title>
<styletype="text/css">
.style1
{
font-size: x-large;
}
.style2
{
font-size: large;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>
<strong><spanclass="style1"> FACTORIAL
NUMBER</span><br/>
<spanclass="style2">&nbsp;Enter Number :</span></strong>&nbsp;
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<br/>
<asp:ButtonID="Button1"runat="server"onclick="Button1_Click"
style="font-weight: 700"Text="SUBMIT"/>
<br/>
<asp:ListBoxID="ListBox1"runat="server"Height="94px"
style="font-weight: 700; color: #00FF00; font-size: large"Width="411px">
</asp:ListBox>

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

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

publicpartialclassfactorial : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{

}
protectedvoid Button1_Click(object sender, EventArgs e)
{
int n, i, f = 1;
n = int.Parse(TextBox1.Text);
for (i = 1; i <= n; i++)

Roll No.: 08 Name :Sudarshan Date Page 18


TYBSc(IT)

{
f = f * i;
}
ListBox1.Items.Add("The Factorial of " + n + " is =" + f);
}
}

ii. Money Conversion

Roll No.: 08 Name :Sudarshan Date Page 19


TYBSc(IT)

money.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="money.aspx.cs"Inherits="money"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title></title>
<styletype="text/css">
.style1
{
font-size: x-large;
}
.style2
{
font-size: large;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>
<strong><spanclass="style1"> MONEY CONVERSION
</span><br/>
<spanclass="style2">&nbsp;Enter Amount :</span></strong>&nbsp;
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<br/>
<asp:ButtonID="Button1"runat="server"onclick="Button1_Click"
style="font-weight: 700"Text="SUBMIT"/>
<br/>
<asp:ListBoxID="ListBox1"runat="server"Height="94px"
style="font-weight: 700; color: #00FF00; font-size: large"Width="411px">
</asp:ListBox>

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

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

publicpartialclassmoney : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{

}
protectedvoid Button1_Click(object sender, EventArgs e)
{
double n;
n = double.Parse(TextBox1.Text);
ListBox1.Items.Add("the value of "+n+" rupees in dollar is= "+(n/63));
}
}

Roll No.: 08 Name :Sudarshan Date Page 20


TYBSc(IT)

b. Create simple application to demonstrate use of following concepts

Roll No.: 08 Name :Sudarshan Date Page 21


TYBSc(IT)

i) Function Overloading

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{
class A
{
private int k;
public void display()
{
k = 1000;
Console.WriteLine("The Value Of K Is: " + k);
}
public void display(int p)
{
k = p;
Console.WriteLine("The Value Of K Is: "+k);
}
}
class B
{
static void Main(string[] args)
{
A x = new A();
x.display();
x.display(3413);
Console.ReadKey();
}
}
}

Output:

ii) INHERITANCE(ALL TYPES)

Roll No.: 08 Name :Sudarshan Date Page 22


TYBSc(IT)

A. Single Inheritance:

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class shape
{
protected int width, height;
public void setwidth(int w)
{
width = w;
}
public void setHeight(int h)
{
height = h;
}
}
class Rectangle : shape
{
public int getArea()
{
return width * height;
}
}
class RectangleTest
{
static void Main(string[] args)
{
Rectangle rect = new Rectangle();
rect.setHeight(7);
rect.setwidth(5);

Console.WriteLine("Area Of A Rectangle Is: " + rect.getArea());


Console.ReadKey();
}
}

Output:

B. Multi-Level Inheritance:

Roll No.: 08 Name :Sudarshan Date Page 23


TYBSc(IT)

Source Code:
using System;
class Abc
{
public void Show()
{
Console.WriteLine("Displayed from main base class Abc");
}
}
class Bbc : Abc
{
public void Display()
{
Console.WriteLine("Displayed from sub base class Bbc");
}
}
class Pqr : Bbc
{
public void ShowMe()
{
Console.WriteLine("Displayed from derived class Pqr");
}
}
class Test
{
public static void Main()
{
Pqr p = new Pqr();
p.Show();
p.Display();
p.ShowMe();
Console.Read();
}
}

Output:

C. Heirarchical Inheritance:

Roll No.: 08 Name :Sudarshan Date Page 24


TYBSc(IT)

Source Code:
using System;
class HeadOffice
{
public void HeadOfficeAddress()
{
Console.WriteLine("Head Office Address");
}
}
class BranchOffice1:HeadOffice
{
public void BranchOfficeAddress()
{
Console.WriteLine("Branch1 Office Address");
}
}
class BranchOffice2 : HeadOffice
{
public void BranchOfficeAddress()
{
Console.WriteLine("Branch2 Office Address");
}
}
class Test
{
static void Main(string[] args)
{
HeadOffice ho = new HeadOffice();
ho.HeadOfficeAddress();
BranchOffice1 bo1 = new BranchOffice1();
bo1.BranchOfficeAddress();
BranchOffice2 bo2 = new BranchOffice2();
bo2.BranchOfficeAddress();
Console.ReadKey();
}
}

Output:

iii) Constructor Overloading.

Roll No.: 08 Name :Sudarshan Date Page 25


TYBSc(IT)

Source Code:
using System;
class Test
{
public Test()
{
Console.WriteLine("Default Constructor of Test class");
}
public Test(int x)
{
Console.WriteLine("Parameterized Constructor of Test class");
}
public Test(string text)
{
Console.WriteLine("Parameterized Constructor of Test class with a string
parameter");
}
static Test()
{
Console.WriteLine("Static Constructor of Test class");
}
}
class Demo
{
public static void Main()
{
Test t = new Test();
Test t1 = new Test(10);
Test t2 = new Test("abc");
Console.Read();
}
}

Output:

iv) Intefaces.

Roll No.: 08 Name :Sudarshan Date Page 26


TYBSc(IT)

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public interface IEmployee
{
void DisplayEmployeeDetails();
}
public interface ICompany
{
void DisplayEmpDetails();
}
public class Employee : IEmployee, ICompany
{
void ICompany.DisplayEmpDetails()
{
Console.WriteLine("ICompany Employee No.: 009");
}
void IEmployee.DisplayEmployeeDetails()
{
Console.WriteLine("ICompany Employee Name: xyz");
}
}
class Program
{
static void Main(string[] args)
{
IEmployee iemp = new Employee();
iemp.DisplayEmployeeDetails();

ICompany icomp = new Employee();


icomp.DisplayEmpDetails();
Console.ReadKey();
}
}
}

Output:

c. Create simple application to demonstrate use of following concepts

Roll No.: 08 Name :Sudarshan Date Page 27


TYBSc(IT)

I. Using Delegates And Events.

A. Delegates:
Source Code:
using System;

//Declare Delegate
public delegate int MyDel(int x,int y);
class Abc
{
public int Add(int a, int b)
{
int c = a + b;
return c;
}
public static int Sub(int x, int y)
{
int z = x - y;
return z;
}
}
class Test
{
public static void Main()
{
Abc a1 = new Abc();

//Delegate initialisation
MyDel m1 = new MyDel(a1.Add);

//Delegate invocation
Console.WriteLine(""+m1(10, 20));
MyDel m2 = new MyDel(Abc.Sub);

//Delegate invocation
Console.WriteLine("" + m2(100, 76));
Console.Read();
}
}

Output:

Roll No.: 08 Name :Sudarshan Date Page 28


TYBSc(IT)

B. Events:
Source Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
label2.Text = "This line is executed on button click event!";
}
}
}

Output:

3. Working with Web Forms and Controls

Roll No.: 08 Name :Sudarshan Date Page 29


TYBSc(IT)

i) TREE VIEW CONTROL

Form Layout:

Default.aspx:
<%@ 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>
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:TreeView>

</div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>

Output:

Roll No.: 08 Name :Sudarshan Date Page 30


TYBSc(IT)

4. Working with Form Controls

Roll No.: 08 Name :Sudarshan Date Page 31


TYBSc(IT)

Create a Registration form to demonstrate use of various Validation controls

Validate.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="validate.aspx.cs"Inherits="validate"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
.style1
{
width: 100%;
}
.style2
{
text-align: right;
}
.style3
{
text-align: center;
}
.style4
{
color: #FF0000;
}
.style5
{
text-align: center;
color: #FF0000;
}
.style6
{
text-align: center;
font-size: x-large;
}
.style7
{
text-align: right;
font-weight: bold;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>

<tableclass="style1"border="0"cellpadding="3px"cellspacing="0px">
<tr>
<tdclass="style2">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style5">
&nbsp;</td>
</tr>
<tr>
<tdclass="style2">

Roll No.: 08 Name :Sudarshan Date Page 32


TYBSc(IT)

&nbsp;</td>
<tdclass="style6"colspan="2">
<strong>REGISTRATION FORM</strong></td>
<tdclass="style5">
&nbsp;</td>
</tr>
<tr>
<tdclass="style2">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style5">
&nbsp;</td>
</tr>
<tr>
<tdclass="style7">
Name&nbsp; :&nbsp;
</td>
<tdclass="style3">
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
</td>
<tdclass="style3">
<asp:RequiredFieldValidatorID="RequiredFieldValidator1"runat="server"
ControlToValidate="TextBox1"ErrorMessage="Enter
name"CssClass="style4"></asp:RequiredFieldValidator>
</td>
<tdclass="style5">
&nbsp;</td>
</tr>
<tr>
<tdclass="style7">
Email&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>
</td>
<tdclass="style3">
<asp:RequiredFieldValidatorID="RequiredFieldValidator2"runat="server"
ControlToValidate="TextBox2"ErrorMessage="Enter
Email"CssClass="style4"></asp:RequiredFieldValidator>
</td>
<tdclass="style3">
<asp:RegularExpressionValidatorID="RegularExpressionValidator1"runat="server"
ControlToValidate="TextBox2"ErrorMessage="Invalid Email"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
CssClass="style4"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<tdclass="style7">
Age&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox3"runat="server"></asp:TextBox>
</td>
<tdclass="style3">
<asp:RequiredFieldValidatorID="RequiredFieldValidator3"runat="server"
ControlToValidate="TextBox3"ErrorMessage="Enter
Age"CssClass="style4"></asp:RequiredFieldValidator>
</td>
<tdclass="style3">
<asp:RangeValidatorID="RangeValidator1"runat="server"
ControlToValidate="TextBox3"ErrorMessage="Enter age between 13 and 50"

Roll No.: 08 Name :Sudarshan Date Page 33


TYBSc(IT)

MaximumValue="50"MinimumValue="13"CssClass="style4"></asp:RangeValidator>
</td>
</tr>
<tr>
<tdclass="style7">
Address&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox6"runat="server"></asp:TextBox>
</td>
<tdclass="style3">
<asp:RequiredFieldValidatorID="RequiredFieldValidator6"runat="server"
ControlToValidate="TextBox6"ErrorMessage="Enter Address"
CssClass="style4"></asp:RequiredFieldValidator>
</td>
<tdclass="style5">
&nbsp;</td>
</tr>
<tr>
<tdclass="style7">
Mobile&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox7"runat="server"></asp:TextBox>
</td>
<tdclass="style3">
<asp:RequiredFieldValidatorID="RequiredFieldValidator7"runat="server"
ControlToValidate="TextBox7"ErrorMessage="Enter Mobile No."
CssClass="style4"></asp:RequiredFieldValidator>
</td>
<tdclass="style3">
<asp:RegularExpressionValidatorID="RegularExpressionValidator2"runat="server"
ControlToValidate="TextBox7"CssClass="style4"
ErrorMessage="Enter 10 digit mobile no."ValidationExpression="^[0-
9]{10}$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<tdclass="style7">
Password&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox4"runat="server"></asp:TextBox>
</td>
<tdclass="style3">
<asp:RequiredFieldValidatorID="RequiredFieldValidator4"runat="server"
ControlToValidate="TextBox4"ErrorMessage="Enter Password"
CssClass="style4"></asp:RequiredFieldValidator>
</td>
<tdclass="style5">
&nbsp;</td>
</tr>
<tr>
<tdclass="style7">
Confirm password&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox5"runat="server"></asp:TextBox>
</td>
<tdclass="style3">
<asp:RequiredFieldValidatorID="RequiredFieldValidator5"runat="server"
ControlToValidate="TextBox5"ErrorMessage="Enter Confirm Password"
CssClass="style4"></asp:RequiredFieldValidator>
</td>
<tdclass="style3">
<asp:CompareValidatorID="CompareValidator1"runat="server"
ControlToCompare="TextBox4"ControlToValidate="TextBox5"

Roll No.: 08 Name :Sudarshan Date Page 34


TYBSc(IT)

ErrorMessage="Password not match"CssClass="style4"></asp:CompareValidator>


</td>
</tr>
<tr>
<tdclass="style7">
&nbsp;</td>
<tdstyle="text-align: center">
<asp:ButtonID="Button1"runat="server"Height="38px"onclick="Button1_Click"
Text="SUBMIT"Width="154px"style="font-weight: 700"/>
</td>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
<td>
<asp:LabelID="Label1"runat="server"
style="font-size: x-large; color: #00CC00;"Text="Label"></asp:Label>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
<asp:ValidationSummaryID="ValidationSummary1"runat="server"
style="font-size: large; color: #FF0000;"/>
</td>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
</table>

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

Roll No.: 08 Name :Sudarshan Date Page 35


TYBSc(IT)

Roll No.: 08 Name :Sudarshan Date Page 36


TYBSc(IT)

5. Working with Navigation, Beautification and Master page


a. Create Web Form to demonstrate use of Website Navigation controls and Site Map

Form Layout:

Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DTH.aspx.cs"
Inherits="DTH" %>
<!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="DTH SECTION"></asp:Label>
<br />
<br />
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
</div>
</form>
</body>
</html>

Output:

Roll No.: 08 Name :Sudarshan Date Page 37


TYBSc(IT)

B Create a web application to demonstrate use of Master Page with applying Styles and Themes
for page beautification.
Masterpage Flow Layout:

MasterPage.Master:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"


Inherits="WebApplication1.Site1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
&nbsp;<asp:LinkButton ID="LinkButton1" runat="server"
PostBackUrl="~/WebForm1.aspx">C#</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server"
PostBackUrl="~/WebForm2.aspx">NS</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server"
PostBackUrl="~/WebForm3.aspx">ST</asp:LinkButton>
<br />
<br />
<br />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<br />
<br />
<br />
</div>
</form>
</body>
</html>

MasterPage.Master.cs:
Roll No.: 08 Name :Sudarshan Date Page 38
TYBSc(IT)

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 Site1 : System.Web.UI.MasterPage


{
protected void Page_Load(object sender, EventArgs e)
{

}
}
}

C#.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"


CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
You Are Viewing C#.
</asp:Content>

NS.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"


CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
You Are Viewing Network Security.
</asp:Content>

ST.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication1.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
You Are Viewing Software Testing.
</asp:Content>

Output:

Roll No.: 08 Name :Sudarshan Date Page 39


TYBSc(IT)

Roll No.: 08 Name :Sudarshan Date Page 40


TYBSc(IT)

6. Working with Database


Demonstrate the use USE OF GridView, DetailsView, ListView CONTROLS.

i) GridView:

Form Layout:

Default.aspx:

<%@ 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>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="RollNo" HeaderText="RollNo"
SortExpression="RollNo" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="PhoneNo" HeaderText="PhoneNo"
SortExpression="PhoneNo" />
<asp:BoundField DataField="Gender" HeaderText="Gender"
SortExpression="Gender" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TYITConnectionString %>"
SelectCommand="SELECT * FROM [tyit] ORDER BY
[Name]"></asp:SqlDataSource>

Roll No.: 08 Name :Sudarshan Date Page 41


TYBSc(IT)

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

Output:

Roll No.: 08 Name :Sudarshan Date Page 42


TYBSc(IT)

ii) DetailsView

Form Layout:

Default.aspx:-
<%@ 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>
<br />
<asp:Label ID="Label1" runat="server" Text="Enter RollNo"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TxtRlno" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="width: 39px" Text="Find" />
<br />
<br />
<br />
<br />
<br />

Roll No.: 08 Name :Sudarshan Date Page 43


TYBSc(IT)

<br />
<br />
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px">
</asp:DetailsView>
<br />
<br />
<br />
</div>
</form>
</body>
</html>

Default.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.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=AYESHA-PC;Initial
Catalog=TYIT;Integrated Security=SSPI");
con.Open();
Label2.Text = "Details of "+TxtRlno.Text+" are as follows";
String query = ("select * from tyit where RollNo =") + TxtRlno.Text;
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
da.Fill(ds);
DetailsView1.DataSource=ds;
DetailsView1.DataBind();
con.Close();
}
}

Roll No.: 08 Name :Sudarshan Date Page 44


TYBSc(IT)

Output:-

Roll No.: 08 Name :Sudarshan Date Page 45


TYBSc(IT)

iii) ListView

Form Layout:

Default.aspx:
<%@ 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>

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">

Roll No.: 08 Name :Sudarshan Date Page 46


TYBSc(IT)

<AlternatingItemTemplate>
<tr style="background-color:#FFF8DC;">
<td>
<asp:Label ID="RollNoLabel" runat="server" Text='<%# Eval("RollNo") %>' />
</td>
<td>
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td>
<asp:Label ID="PhoneNoLabel" runat="server" Text='<%# Eval("PhoneNo") %>' />
</td>
<td>
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color:#008A8C;color: #FFFFFF;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
</td>
<td>
<asp:TextBox ID="RollNoTextBox" runat="server" Text='<%# Bind("RollNo") %>' />
</td>
<td>
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
</td>
<td>
<asp:TextBox ID="PhoneNoTextBox" runat="server" Text='<%# Bind("PhoneNo") %>'
/>
</td>
<td>
<asp:TextBox ID="GenderTextBox" runat="server" Text='<%# Bind("Gender") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color:
#999999;border-style:none;border-width:1px;">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">

Roll No.: 08 Name :Sudarshan Date Page 47


TYBSc(IT)

<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
<asp:TextBox ID="RollNoTextBox" runat="server" Text='<%# Bind("RollNo") %>' />
</td>
<td>
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
</td>
<td>
<asp:TextBox ID="PhoneNoTextBox" runat="server" Text='<%# Bind("PhoneNo") %>'
/>
</td>
<td>
<asp:TextBox ID="GenderTextBox" runat="server" Text='<%# Bind("Gender") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color:#DCDCDC;color: #000000;">
<td>
<asp:Label ID="RollNoLabel" runat="server" Text='<%# Eval("RollNo") %>' />
</td>
<td>
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td>
<asp:Label ID="PhoneNoLabel" runat="server" Text='<%# Eval("PhoneNo") %>' />
</td>
<td>
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-
color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial,
Helvetica, sans-serif;">
<tr runat="server" style="background-color:#DCDCDC;color: #000000;">
<th runat="server">
RollNo</th>
<th runat="server">
Name</th>
<th runat="server">

Roll No.: 08 Name :Sudarshan Date Page 48


TYBSc(IT)

PhoneNo</th>
<th runat="server">
Gender</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #CCCCCC;font-family:
Verdana, Arial, Helvetica, sans-serif;color: #000000;">
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
<asp:Label ID="RollNoLabel" runat="server" Text='<%# Eval("RollNo") %>' />
</td>
<td>
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td>
<asp:Label ID="PhoneNoLabel" runat="server" Text='<%# Eval("PhoneNo") %>' />
</td>
<td>
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TYITConnectionString %>"
SelectCommand="SELECT * FROM [tyit]"></asp:SqlDataSource>

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

Roll No.: 08 Name :Sudarshan Date Page 49


TYBSc(IT)

Output:

Roll No.: 08 Name :Sudarshan Date Page 50


TYBSc(IT)

7. Working with Database


a. Create a web application to display Databinding using dropdownlist control. OR
b. Create a web application for to display the phone no of an author using database.
Disp.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Disp.aspx.cs"Inherits="Disp"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">

.style2
{
width: 100%;
}
.style3
{
width: 143px;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>

<br/>
<tableclass="style2">
<tr>
<tdclass="style3">
ID</td>
<tdalign="left"style="width: 308px">
<asp:DropDownListID="DropDownList1"runat="server"
DataSourceID="SqlDataSource1"DataTextField="id"DataValueField="id"
onselectedindexchanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"
ConnectionString="<%$ ConnectionStrings:updatConnectionString3 %>"
SelectCommand="SELECT [id] FROM [harshadmi]"></asp:SqlDataSource>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<tdclass="style3">
NAME</td>
<tdalign="left"style="width: 308px">
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<tdclass="style3">
ADDRESS</td>
<tdalign="left"style="width: 308px">
<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>
</td>
<td>

Roll No.: 08 Name :Sudarshan Date Page 51


TYBSc(IT)

&nbsp;</td>
</tr>
<tr>
<tdclass="style3">
MOBILE NO.</td>
<tdalign="left"style="width: 308px">
<asp:TextBoxID="TextBox3"runat="server"></asp:TextBox>
</td>
<td>
&nbsp;</td>
</tr>
</table>

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

Disp.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.Data;
using System.Data.SqlClient;
publicpartialclassDisp : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
String serverPath = "Data Source=HARSH;Initial Catalog=updat;Integrated Security=True";
SqlConnection con = newSqlConnection(serverPath);
con.Open();
string qry = "select Name , address , mobile from harshadmi where id=" + DropDownList1.Text + "";
SqlCommand com = newSqlCommand(qry, con);
SqlDataReader dr;
dr = com.ExecuteReader();
while (dr.Read())
{
TextBox1.Text = dr["name"].ToString();
TextBox2.Text = dr["address"].ToString();
TextBox3.Text = dr["mobile"].ToString();
}
dr.Close();
}
}

c. Create a web application for inserting and deleting record from a database. (Using Execute-Non
Query).

Roll No.: 08 Name :Sudarshan Date Page 52


TYBSc(IT)

Upd.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Upd.aspx.cs"Inherits="validate"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
.style1
{
width: 100%;
}
.style2
{
text-align: right;
}
.style3
{
text-align: center;
}
.style4
{
color: #FF0000;
}
.style5
{
text-align: center;
color: #FF0000;
}
.style6
{
text-align: center;
font-size: x-large;
}
.style7
{
text-align: right;
font-weight: bold;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>

<tableclass="style1"border="0"cellpadding="3px"cellspacing="0px">
<tr>
<tdclass="style2">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style3">
&nbsp;</td>
<tdclass="style5">
&nbsp;</td>
</tr>
<tr>
<tdclass="style2">
&nbsp;</td>
<tdclass="style6"colspan="2">
<strong>REGISTRATION FORM</strong></td>

Roll No.: 08 Name :Sudarshan Date Page 53


TYBSc(IT)

<tdclass="style5">
&nbsp;</td>
</tr>
<tr>
<tdclass="style7">
Name&nbsp; :&nbsp;
</td>
<tdclass="style3">
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<tdclass="style7">
Email&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<tdclass="style7">
Age&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox3"runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<tdclass="style7">
Address&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox6"runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<tdclass="style7">
Mobile&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox7"runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<tdclass="style7">
Password&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox4"runat="server"TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<tdclass="style7">
Confirm password&nbsp; :</td>
<tdclass="style3">
<asp:TextBoxID="TextBox5"runat="server"TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<tdclass="style7">
&nbsp;</td>
<tdstyle="text-align: center">
<asp:ButtonID="Button1"runat="server"Height="38px"onclick="Button1_Click"
Text="SUBMIT"Width="154px"style="font-weight: 700"/>
</td>
</tr>
<tr>
<td>

Roll No.: 08 Name :Sudarshan Date Page 54


TYBSc(IT)

&nbsp;</td>
<td>
<asp:LabelID="Label1"runat="server"
style="font-size: x-large; color: #00CC00;"Text="Label"></asp:Label>
</td>
</tr>
<tr>
<tdstyle="text-align: right; font-weight: 700">
Enter ID&nbsp; :</td>
<tdstyle="text-align: center">
<asp:TextBoxID="TextBox8"runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<tdstyle="text-align: center">
<asp:ButtonID="Button2"runat="server"Height="32px"onclick="Button2_Click"
style="font-weight: 700"Text="DELETE"Width="131px"/>
</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
<td>
<asp:LabelID="Label2"runat="server"
style="font-size: x-large; color: #00CC00;"Text="Label"></asp:Label>
</td>
<td>
&nbsp;</td>
</tr>
</table>

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

Upd.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.Data;
using System.Data.SqlClient;

publicpartialclassvalidate : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
Label1.Visible = false;
Label2.Visible = false;
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
String serverPath = "Data Source=HARSH;Initial Catalog=updat;Integrated Security=True";
SqlConnection con = newSqlConnection(serverPath);
con.Open();

Roll No.: 08 Name :Sudarshan Date Page 55


TYBSc(IT)

String insertQuery = "insert into abc values ('" + TextBox1.Text + "','" + TextBox2.Text + "', '"
+ TextBox3.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "', '" + TextBox4.Text + "', '"
+ TextBox5.Text + "')";
SqlCommand com = newSqlCommand(insertQuery, con);
com.ExecuteNonQuery();
Label1.Text = "Record Submitted Successfully";
Label1.Visible = true;
}
protectedvoid Button2_Click(object sender, EventArgs e)
{
String serverPath = "Data Source=HARSH;Initial Catalog=updat;Integrated Security=True";
SqlConnection con = newSqlConnection(serverPath);
con.Open();
string qry = "delete from abc where id=" + TextBox8.Text + "";
SqlCommand com = newSqlCommand(qry, con);
com.ExecuteNonQuery();
con.Close();
Label2.Text = "Record Deleted Successfully";
Label2.Visible = true;
}
}

Roll No.: 08 Name :Sudarshan Date Page 56


TYBSc(IT)

Deleting

8. Working with data controls


Create a web application to display Using Disconnected Data Access and Databinding using
GridView.
validate.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="validate.aspx.cs"Inherits="validate"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
.style1
{
width: 100%;
}
</style>

Roll No.: 08 Name :Sudarshan Date Page 57


TYBSc(IT)

</head>
<body>
<formid="form1"runat="server">
<div>
<tableclass="style1"border="0"cellpadding="3px"cellspacing="0px">
<tr>
<td>
&nbsp;</td>
<tdcolspan="2"style="text-align: center">
<asp:GridViewID="GridView1"runat="server"CellPadding="4"ForeColor="#333333"
GridLines="None"Height="129px"Width="314px">
<AlternatingRowStyleBackColor="White"/>
<EditRowStyleBackColor="#2461BF"/>
<FooterStyleBackColor="#507CD1"Font-Bold="True"ForeColor="White"/>
<HeaderStyleBackColor="#507CD1"Font-Bold="True"ForeColor="White"/>
<PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"/>
<RowStyleBackColor="#EFF3FB"/>
<SelectedRowStyleBackColor="#D1DDF1"Font-Bold="True"ForeColor="#333333"/>
<SortedAscendingCellStyleBackColor="#F5F7FB"/>
<SortedAscendingHeaderStyleBackColor="#6D95E1"/>
<SortedDescendingCellStyleBackColor="#E9EBEF"/>
<SortedDescendingHeaderStyleBackColor="#4870BE"/>
</asp:GridView>
</td>
<td>
&nbsp;</td>
</tr>
</table>

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

Validate.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.Data;
using System.Data.SqlClient;

publicpartialclassvalidate : System.Web.UI.Page
{
SqlConnection con = newSqlConnection("Data Source=HARSH;Initial Catalog=updat;Integrated
Security=True");
protectedvoid Page_Load(object sender, EventArgs e)
{
SqlDataAdapter sda = newSqlDataAdapter("select * from abc", con);
DataTable dt = newDataTable();
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
con.Close();

Roll No.: 08 Name :Sudarshan Date Page 58


TYBSc(IT)

Label1.Visible = false;
}
}

9. Working with GridView control


a. Create a web application to demonstrate use of GridView button column and GridView events.
AND
b. Create a web application to demonstrate GridView paging and Creating own table format using
GridView.
validate.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="validate.aspx.cs"Inherits="validate"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0


Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
.style1
{
width: 100%;
}
</style>
</head>

Roll No.: 08 Name :Sudarshan Date Page 59


TYBSc(IT)

<body>
<formid="form1"runat="server">
<div>

<tableclass="style1"border="0"cellpadding="3px"cellspacing="0px">
<tr>
<td>
&nbsp;</td>
<tdcolspan="2"style="text-align: center">
<asp:GridViewID="GridView1"runat="server"AllowPaging="True"
AllowSorting="True"AutoGenerateColumns="False"CellPadding="4"
DataKeyNames="id"DataSourceID="SqlDataSource1"ForeColor="#333333"
GridLines="None"Height="129px"PageSize="5"Width="314px">
<AlternatingRowStyleBackColor="White"/>
<Columns>
<asp:CommandFieldShowSelectButton="True"/>
<asp:BoundFieldDataField="id"HeaderText="id"InsertVisible="False"
ReadOnly="True"SortExpression="id"/>
<asp:BoundFieldDataField="name"HeaderText="name"SortExpression="name"/>
<asp:BoundFieldDataField="email"HeaderText="email"SortExpression="email"/>
<asp:BoundFieldDataField="age"HeaderText="age"SortExpression="age"/>
<asp:BoundFieldDataField="address"HeaderText="address"
SortExpression="address"/>
<asp:BoundFieldDataField="mobile"HeaderText="mobile"
SortExpression="mobile"/>
<asp:BoundFieldDataField="psd"HeaderText="psd"SortExpression="psd"/>
<asp:BoundFieldDataField="conpsd"HeaderText="conpsd"
SortExpression="conpsd"/>
<asp:CommandFieldHeaderText="Update"ShowEditButton="True"/>
<asp:CommandFieldHeaderText="Delete"ShowDeleteButton="True"/>
</Columns>
<EditRowStyleBackColor="#2461BF"/>
<FooterStyleBackColor="#507CD1"Font-Bold="True"ForeColor="White"/>
<HeaderStyleBackColor="#507CD1"Font-Bold="True"ForeColor="White"/>
<PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"/>
<RowStyleBackColor="#EFF3FB"/>
<SelectedRowStyleBackColor="#D1DDF1"Font-Bold="True"ForeColor="#333333"/>
<SortedAscendingCellStyleBackColor="#F5F7FB"/>
<SortedAscendingHeaderStyleBackColor="#6D95E1"/>
<SortedDescendingCellStyleBackColor="#E9EBEF"/>
<SortedDescendingHeaderStyleBackColor="#4870BE"/>
</asp:GridView>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"
ConnectionString="<%$ ConnectionStrings:updatConnectionString %>"
DeleteCommand="DELETE FROM abc where id=@id"
SelectCommand="SELECT * FROM [abc]"
UpdateCommand="UPDATE abc SET name = @name, email = @email, age = @age, address = @address,
mobile = @mobile, psd = @psd, conpsd = @conpsd WHERE (id = @id)">
<DeleteParameters>
<asp:ParameterName="id"/>
</DeleteParameters>
<UpdateParameters>
<asp:ParameterName="name"/>
<asp:ParameterName="email"/>
<asp:ParameterName="age"/>
<asp:ParameterName="address"/>
<asp:ParameterName="mobile"/>
<asp:ParameterName="psd"/>
<asp:ParameterName="conpas"/>
<asp:ParameterName="id"/>
<asp:ParameterName="conpsd"/>
</UpdateParameters>
</asp:SqlDataSource>

Roll No.: 08 Name :Sudarshan Date Page 60


TYBSc(IT)

</td>
<td>
&nbsp;</td>
</tr>
</table>

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

Select

Paging

Roll No.: 08 Name :Sudarshan Date Page 61


TYBSc(IT)

10. Working with AJAX and XML


I).SCRIPTMANAGERCONTROL
II).TIMER CONTROL
III).UPDATEPANEL CONTROL
IV).UPDATEPROGRESS CONTROL

i) ScriptManager Control And UpdatePanel Control:


Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"


Inherits="_Default" %>

Roll No.: 08 Name :Sudarshan Date Page 62


TYBSc(IT)

<!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:ScriptManager ID="ScriptManager1" runat="server">


</asp:ScriptManager>
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label2" runat="server" style="font-size: xx-large"></asp:Label><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Change both"
onclick="Button1_Click" style="font-size: x-large" /><br />
<asp:Button ID="Button2" runat="server" Text="Change only this"
onclick="Button2_Click" style="font-size: x-large" />
</ContentTemplate>
</asp:UpdatePanel>
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" style="font-size: xx-large"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click">
</asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

Default.aspx.cs:
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


{

Roll No.: 08 Name :Sudarshan Date Page 63


TYBSc(IT)

protected void Page_Load(object sender, EventArgs e)


{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = System.DateTime.Now.ToLongTimeString();
Label2.Text = System.DateTime.Now.ToLongTimeString();
}
protected void Button2_Click(object sender, EventArgs e)
{
Label2.Text = System.DateTime.Now.ToLongTimeString();
}
}
Output:

ii) TIMER CONTROL:


Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs"


Inherits="Default3" %>

<!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>

Roll No.: 08 Name :Sudarshan Date Page 64


TYBSc(IT)

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="click">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="tick" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

Default.aspx.cs:

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

public partial class Default3 : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

protected void click(object sender, EventArgs e)


{
Label1.Text = DateTime.Now.ToLongTimeString();
}
}

Output:

Roll No.: 08 Name :Sudarshan Date Page 65


TYBSc(IT)

iii) UpdateProgress Control:


Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"


Inherits="Default2" %>

Roll No.: 08 Name :Sudarshan Date Page 66


TYBSc(IT)

<!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:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div style="background-color:#FFFFE0;padding: 20px">
<asp:Label ID="lblTime" runat="server" Font-Bold="True"></asp:Label>
<br /><br />
<asp:Button ID="Button1" runat="server" OnClick="cmdRefreshTime_Click"
Text="Start the Refresh Process" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdateProgress ID="updateProgress1" runat="server">
<ProgressTemplate>
<div style="font-size: xx-small">
<asp:Image ID="Image1" runat="server" Height="140px"
ImageUrl="~/Please_wait (1).gif" Width="539px" />
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
</body>
</html>

Default.aspx.cs;

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

public partial class Default2 : System.Web.UI.Page


{

Roll No.: 08 Name :Sudarshan Date Page 67


TYBSc(IT)

protected void Page_Load(object sender, EventArgs e)


{

protected void cmdRefreshTime_Click(object sender, EventArgs e)


{
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));
lblTime.Text = DateTime.Now.ToLongTimeString();

}
}

Output:

Roll No.: 08 Name :Sudarshan Date Page 68

You might also like