0% found this document useful (0 votes)
9 views

ASP C# practical programs

Uploaded by

pnana7273
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

ASP C# practical programs

Uploaded by

pnana7273
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 99

TYBSc(IT) Advance Web Programming

SMT. SUSHILADEVI DESHMUKH COLLEGE OF ARTS,


SCIENCE AND COMMERCE, Airoli, Navi Mumbai – 400 708

Date: __________
Certificate
This is to certify that Mr./Miss___________________________________ seat no __________
of TYBSc IT Semester ____ has completed the practical work in the subject of
“___________________________________” during the academic year 2020 – 21 under the
guidance of Prof. _____________________________________ being the partial requirement for
the fulfilment of the curriculum of Degree of Bachelor of Information Technology, University of
Mumbai.

Signature of Internal Guide Signature of HOD

College Seal

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

INDEX
Sr. No. Practical’s Date Sign.
1. SIMPLE PROGRAMS WITH C#:
a. Write a console application that obtain four int values
1. from user and display the product. hint: you may recall
that the Convert.ToDouble() command was used to
convert from a string to an int is Convert.ToInt32().
Object oriented programs with c#.
2. a. Program Using Classes.

3.

4.

5.

6.

7.

8.

9.

10.

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

1. SIMPLE PROGRAMS WITH C#:


a. Write a console application that obtain four int values from user and display the
product. hint: you may recall that the Convert.ToDouble() command was used
to convert from a string to an int is Convert.ToInt32().

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, b, c, d, e;
Console.WriteLine("Enter First Number: ");
a = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter Second Number: ");


b = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter Third Number: ");


c = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter Fourth Number: ");


d = Convert.ToInt32(Console.ReadLine());

e = a * b * c * d;
Console.WriteLine("The Product Of A Given Number: "+e);
Console.ReadKey();
}
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

b. If you have two integers stored in variable var1 and var2, what boolean test can
you perform to see if one or the other (but not both) is greater than 10?

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int var1, var2;
Console.WriteLine("Enter Two Numbers: ");
var1 = Convert.ToInt16(Console.ReadLine());
var2 = Convert.ToInt16(Console.ReadLine());
if (var1 > 10 || var2 > 10)
{
if (var1 > var2)
{
Console.WriteLine(var1 + " Is Greater Than " + var2);
}
else
{
Console.WriteLine(var2 + " Is Greater Than " + var1);
}
}
else
{
Console.WriteLine("Enter A Number Which Is Greater Than 10...!!!");
}
Console.ReadKey();
}
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

c. Write A Console Application That Include The Logic From Exercise 1, Obtains
Two Numbers From The User, And Display Them, But Rejects Any Input
Where Both Numbers Are Greater Than 10 And Asks For Two New Numbers.

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

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int var1, var2;
abc:
Console.WriteLine("Enter Two Numbers: ");
var1 = Convert.ToInt16(Console.ReadLine());
var2 = Convert.ToInt16(Console.ReadLine());

if (var1 > 10 && var2 > 10)


{
Console.WriteLine("Enter The Number Which Is Less Than
10...!!!");
goto abc;
}
else
{
Console.WriteLine();
}
Console.WriteLine("First Number Is: " + var1);
Console.WriteLine("Second Number Is: " + var2);
Console.ReadKey();
}
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

d. Write a console application that places double quotation marks around each
word in a string.

Source Code:
using System;
class doubleQuote
{
static void Main(string[] args)
{
start:
string myString;
char[] separator = { ' ' };
Console.WriteLine("Type any string please");
myString = Console.ReadLine();
string[] myWords;
myWords = myString.Split(separator);

foreach (string word in myWords)


{
Console.Write("\"{0}\" ", word);
}

Console.WriteLine();
Console.ReadKey();
Console.Clear();

goto start;
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

e. Write a console application that uses command-line arguments to place value


into a string and an integer variable respectively. Then display these values.

Source Code:
using System;
namespace PRAC1._5
{
class Program
{
public static void Main(String[] args)
{
Console.WriteLine(""+args[0]);
Console.WriteLine(""+args[1]);
Console.ReadKey();
}
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

f. Write an application that receives the following information from a set of


student:
STUDENT ID:
STUDENT NAME:
COURCE NAME:
DATE OF BIRTH:
The application should also display the information of all the student once the
data is entered, implement this using an array of Structs.

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
struct Student
{
int stud_id;
string stud_name, course_name, stud_dob;
public Student(int i, string j, string k, string l)
{
stud_id = i;
stud_name = j;
course_name = k;
stud_dob = l;
}
public void Display()
{
Console.WriteLine("{0} {1} {2} {3}", stud_id,
stud_name, course_name, stud_dob);
}
}
class Program
{
static void Main()
{
Student[] ob1 = new Student[3]; //array of structure created 3 element
for (int a = 0; a < 3; a++)
{
Console.Write("enter the student id =");
int id = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the student name =");
string str = Console.ReadLine();
Console.Write("enter the course name =");
string str1 = Console.ReadLine();
Console.Write("Enter the student dob =");
string str2 = Console.ReadLine();

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

ob1[a] = new Student(id, str, str1, str2);


}
Console.WriteLine(" STUDENT INFORMATION ");
Console.WriteLine("------------------------------------------------------------");
Console.WriteLine("student_id Student_name course_name
student_dob ");
Console.WriteLine("------------------------------------------------------------");

for (int r = 0; r < 3; r++)


{
ob1[r].Display();
}
Student obj = new Student();
obj.Display();
Console.ReadKey();
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

g. Write Programs Using Conditional Statements And Loop.


i. Generate fibonacci series.

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

namespace ConsoleApplication4
{
class Program
{
public static int fibonacci(int n)
{
int a = 0;
int b = 1;
for (int i = 0; i < n; i++)
{
int temp = a;
a = b;
b = temp + b;
}
return a;
}
static void Main(string[] args)
{
int r;
abc:
Console.WriteLine("Enetr The Length Of Fibonacci Series: ");
r = Convert.ToInt16(Console.ReadLine());
for (int i = 0; i < r; i++)
{
Console.Write(" " + fibonacci(i));
}
Console.ReadKey();
}
}
}
Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

ii. Generate Various Pattern(Triangle,Diamond And Other Patterns)With


Number.
A.

Source Code:

using System;
class pattern
{
public static void Main()
{
int x;

Console.Write("Enter The Number of rows : " );


x=(int.Parse)(Console.ReadLine());

for(int i=1;i<=x;i++)
{
for(int j=1;j<=i;j++)
{
Console.Write(i+ " ");
}
Console.WriteLine();
}
Console.ReadKey();

}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

B.
Source Code:
using System;
class pattern
{
public static void Main()
{
int x;

Console.Write("Enter The Number of rows : " );


x=(int.Parse)(Console.ReadLine());

for(int i=1;i<=x;i++)
{
for(int j=x;j>=i;j--)
{
Console.Write(" " + "$" + " ");
}
Console.WriteLine();
}
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

C.

Source Code:-
using System;

class pattern1
{
public static void Main()
{
int x;

Console.Write("Enter The Number of rows : " );


x=(int.Parse)(Console.ReadLine());

for(int i=1;i<=x;i++)
{
for(int j=x;j>i;j--)
{
Console.Write(" ");
}
for(int k=1;k<=i;k++)
{
Console.Write(i+" ");
}
Console.WriteLine();
}
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

iii. Test For Prime Number

Sourcecode:
using System;
class edit
{
public bool Prime(int x)
{
int flag=0;
bool r;
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;
return r;
}
public static void Main()
{
int i;
bool result;
Console.WriteLine("Enter the number:");
i=int.Parse(Console.ReadLine());
edit obj=new edit();
result=obj.Prime(i);
Console.WriteLine(result);
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

iv. Generate prime numnbers

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

namespace ConsoleApplication6
{
class Program
{
static bool IsPrimeNumber(int num)
{
bool bPrime = true;
int factor = num / 2;
int i = 0;
for (i = 2; i <= factor; i++)
{
if ((num % i) == 0)
bPrime = false;
} return bPrime;
}
static void Main(string[] args)
{
int i,r;
Console.WriteLine("Enteer Length: ");
r = Convert.ToInt16(Console.ReadLine());

Console.WriteLine("List Of Prime Numbers between 0-"+r+" Is\n");


for (i = 0; i <= r;i++)
{
if (IsPrimeNumber(i) == true)
Console.WriteLine("{0,8}\t", +i);
}
Console.WriteLine();
Console.ReadLine();
}
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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

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

namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter A Number: ");
int num = int.Parse(Console.ReadLine());
int rev = 0, temp = 0, sum = 0;
while (num > 0)
{
temp = num % 10;
rev = rev * 10 + temp;
num = num / 10;
sum = sum + temp;
}
Console.WriteLine("Reverse Number Is: " + rev);
Console.WriteLine("Sum Of The Digits Is: " + sum);
Console.ReadKey();
}
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

vi. Test for vowels.

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

namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
char c;
Console.Write("Enter Any Charecter: ");
c = Convert.ToChar(Console.ReadLine());
switch (c)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U': Console.Write("'"+c+"' Is A Vowel...!!!");

break;

default: Console.Write("'" + c + "' Is A Consonents...!!!");


break;
}
Console.ReadLine();
}
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

vii. Use of foreach loop with array.

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

namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
int[] myArray = { 20, 21, 22, 23 };
foreach (int m in myArray)
{
Console.Write(" " + m);
}
Console.ReadLine();
}
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

2. Object oriented programs with c#.


a. Program Using Classes.
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Abc {
public void Show() {
Console.WriteLine("Show called from class Abc");
}

}
class Test {
public static void Main() {
Abc a = new Abc();
a.Show();
Console.Read();
}
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

b. Program With Different Feature Of C#.

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:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

ii) INHERITANCE(ALL TYPES)

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();
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

B. Multi-Level Inheritance:
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:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

C. Heirarchical Inheritance:
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:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

iii) Constructor Overloading.

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:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

iv) Intefaces.

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:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

v) 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 :- Name:-
TYBSc(IT) Advance Web Programming

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!";
}
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Common Steps for ASP.NET


1. User left click on "File (menu item)" in "Start Page - Microsoft Visual Studio"

2. User left click on "Web Site... (menu item)"

3. User left click on "ASP.NET Empty Web Site (list item)" in "New Web Site"

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

4. User left click on "OK (push button)" in "New Web Site"

5. User right click on "E:\...\WebSite4\ (outline item)" in "WebSite4 - Microsoft Visual


Studio"

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

6. User left click on "Add New Item... (menu item)"

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

7. User left click on "_Add (text)" in "Add New Item - E:\KHAN\Study\TYIT sem V\
WebSite4\"

8.

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

3. ASP.NET application using server controls to get the user data as roll
number(listbox), name(textbox), password(textbox), gender(radiobutton),
hobbies(checkboxlist), dob(calender) show above data on another form.

Form Layout:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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:Label ID="Label1" runat="server" Text="Enter Name"></asp:Label>


:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="Name" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Enter RollNo.:"></asp:Label>
&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="Rno" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label3" runat="server" Text="Enter Password"></asp:Label>
:
<asp:TextBox ID="Pwd" runat="server" style="margin-bottom: 0px"
TextMode="Password"></asp:TextBox>
<br />
<asp:Label ID="Label4" runat="server" Text="Gender"></asp:Label>
&nbsp;<asp:RadioButtonList ID="Gd" runat="server">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Label ID="Label5" runat="server" Text="Hobbies"></asp:Label>
<asp:CheckBoxList ID="Hb" runat="server">
<asp:ListItem>Singing</asp:ListItem>
<asp:ListItem>Dancing</asp:ListItem>
<asp:ListItem>Reading</asp:ListItem>
</asp:CheckBoxList>
<br />
<asp:Label ID="Label6" runat="server" Text="DOB"></asp:Label>
&nbsp;&nbsp;&nbsp;

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

<asp:Calendar ID="Dob" runat="server" BackColor="White" BorderColor="White"


BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black"
Height="190px" NextPrevFormat="FullMonth" Width="350px">
<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>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="SUBMIT" />
</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


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

}
protected void Button1_Click(object sender, EventArgs e)
{
String name, rn, pwd, gd, hb, dob;
name = Server.UrlEncode(Name.Text);
rn = Server.UrlEncode(Rno.Text);
int rno=Convert.ToInt32(rn);

pwd = Server.UrlEncode(Pwd.Text);
gd = Server.UrlEncode(Gd.Text);
hb = Server.UrlEncode(Hb.Text);
dob=Server.UrlEncode(Dob.SelectedDate.Date.ToString());

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

String Url = "Read.aspx?" + "&nn=" + name + "&rr=" + rn + "&pd=" + pwd +


"&gg=" + gd + "&hh=" + hb+"&dd="+dob;
Response.Redirect(Url);
}
}

Read.aspx(Layout):

Read.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Read.aspx.cs"
Inherits="Read" %>

<!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="Label"></asp:Label>


<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
Label<br />
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>

</div>

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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

Read.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 Read : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
String name = Server.UrlDecode(Request.QueryString["nn"]);
String rno = Server.UrlDecode(Request.QueryString["rr"]);
String pwd = Server.UrlDecode(Request.QueryString["pd"]);
String gd = Server.UrlDecode(Request.QueryString["gg"]);
String hb = Server.UrlDecode(Request.QueryString["hh"]);
String dob = Server.UrlDecode(Request.QueryString["dd"]);

Label1.Text = "User Name :" + name;


Label2.Text = "User RollNo. :" + rno;
Label3.Text = "User Password :" + pwd;
Label4.Text = "User Gender :" + gd;
Label5.Text = "User Hobbies :" + hb;
Label6.Text = "User DOB :" + dob;
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

4. ASP.NET APPLICATION USING


i) Inline CSS(Using In Tag Only)

Form Layout:

Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<h1 style="color:Lime" >Heading1</h1>
<h2>Heading2</h2>
</body>
</html>

Output:

ii) Internal/Embedded CSS(In <script> and <script>tag).

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Form Layout:

Default2.aspx :
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<style type="text/css">
h2 {color:Orange; font-family:Arabic Typesetting; font-size:30pt};
</style>
</head>
<body>
<h1>Heading1</h1>
<h2>Heading2</h2>
</body>
</html>

Output:

iii) External CSS(using .CSS file).

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Form Layout:

Default2.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" />
</head>
<body>
<h1>Heading1</h1>
<h2>Heading2</h2>
</body>
</html>

StyleSheet.css:
body
{
background:cyan;
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

5. Develop a simple asp.net application to demonstrate the use of ispostback property.

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:DropDownList ID="DropDownList1" runat="server">


<asp:ListItem>USA</asp:ListItem>
<asp:ListItem>INDIA</asp:ListItem>
</asp:DropDownList>

</div>
<asp:Button ID="Button1" runat="server" Height="39px" onclick="Button1_Click"
style="z-index: 1; left: 86px; top: 15px; position: absolute"
Text="SELECT COUNTRY" Width="168px" />
<br />
<br />
<asp:Label ID="Label1" runat="server"
style="z-index: 1; left: 130px; top: 76px; position: absolute" Text="Label"
Visible="False"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Your Selection Is: &quot;"></asp:Label>
<br />
<br />
<asp:Label ID="Label3" runat="server"

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

style="z-index: 1; left: 173px; top: 75px; position: absolute; width: 5px"


Text="&quot;"></asp:Label>
</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


{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DropDownList1.DataBind();
}

}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedItem.Text;
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

6. DEVELOP ASP.NET APPLICATION TO DEMONSTRATE FOLLOWING


ELEMENTS OF WEB FORM. USE COMMENTS.
(i) Directive
(ii) Code declaration block
(iii) Code render block
(iv) ASP.NET server controls
(v) Server side comments
(vi) Literal text and HTML controls/tags

<%@ Page Language="C#" AutoEventWireup="true"


CodeFile="Default.aspx.cs" Theme="SkinFile" Inherits="_Default" %>//This
line is called as a “directive”.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


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

///Three slashes make up a XML comment/Server Side Comment

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">//This is the start of the code declaration block


<title></title>
</head>

<body bgcolor= "yellow">//This is the start of the code render block


<form id="form1" runat="server">
<div>

<h1 style="color:Green">This is a heading</h1>//This is a HTML control used


for displaying a heading

<asp:Label ID="Label1" runat="server" Text="Label" SkinID=LblSkin>This is a


label!</asp:Label>//This is an //ASP.NET server control

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

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

7. CREATE AN EMAIL REGISTRATION FORM AND USE ALL OF THE


FOLLOWING CONTROLS TO VALIDATE ENTERED DATA:
(RequireFieldValidator, CompareValidator, CustomValidator, RangeValidator,
ValidationSummary)

Form Layout:

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

<!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 id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

User Registration Form<br />


<br />
Fields marked with &quot;*&quot; are mandatory to be filled<br />
<br />

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

User
Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
*<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Name cannot be left
blank"></asp:RequiredFieldValidator>
&nbsp;&nbsp;&nbsp;
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ErrorMessage="Username must be between 4 and 64 characters"
ControlToValidate="TextBox1"
ValidationExpression="^[\s\S]{4,64}$"></asp:RegularExpressionValidator>
<br />

Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
*<br />
Confirm Password: <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
*<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox2" ControlToValidate="TextBox3"
ErrorMessage="Passwords do not match"></asp:CompareValidator>
<br />
Email
ID:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
*<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="TextBox4" ErrorMessage="Not a valid email
id"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></
asp:RegularExpressionValidator>
<br />

Age:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
*<asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToValidate="TextBox5" ErrorMessage="Age must be &gt;18"
ValueToCompare="18"></asp:CompareValidator>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="Submit" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
</div>
</form>
</body>

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

</html>
Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

8. DEVLOP AN APPLICATION TO COUNT NUMBER OF VISITORS TO YOUR


WEBSITE USING APPLICATION OBJECT.

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 id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</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


{
protected void Page_Load(object sender, EventArgs e)
{
int a;
a = Convert.ToInt32((Application["myCount"]));
Label1.Text = Convert.ToString(a);
if (a < 10)
Label1.Text = "000" + Label1.Text;
else if (a < 100)

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Label1.Text = "00" + Label1.Text;


else if (a < 1000)
Label1.Text = "0" + Label1.Text;
}
}

Global.aspx:
<%@ Application Language="C#" %>

<script runat="server">
public static int count = 0;
void Application_Start(object sender, EventArgs e)
{
Application["myCount"] = count;
}

void Application_End(object sender, EventArgs e)


{
}

void Application_Error(object sender, EventArgs e)


{
}

void Session_Start(object sender, EventArgs e)


{
count = Convert.ToInt32(Application["myCount"]);
Application["myCount"] = count + 1;
}

void Session_End(object sender, EventArgs e)


{
}
</script>

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

9. DEVLOP AN APPLICATION NAME AND TWO NUMBERS AND DISPLAY


NAME AND GREATEST NUMBER ON ANOTHER PAGE.(USE
QueryString/ViewState)

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:Label ID="Label1" runat="server" Text="Enter Your Name:"></asp:Label>


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Enter First Number:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label3" runat="server" Text="Enter Second Number:"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Compare" />

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

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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


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

}
protected void Button1_Click(object sender, EventArgs e)
{
String name = Server.UrlEncode(TextBox1.Text);
String num1 = Server.UrlEncode(TextBox2.Text);
String num2 = Server.UrlEncode(TextBox3.Text);
int n1 = Convert.ToInt16(num1);
int n2 = Convert.ToInt16(num2);
int n3;
if (n1 > n2)
n3 = n1;
else
n3 = n2;
String nn1 =Server.UrlEncode(Convert.ToString(n1));
string nn2 = Server.UrlDecode(Convert.ToString(n2));
String nn3 = Server.UrlEncode(Convert.ToString(n3));
String Url = "Result.aspx?" + "nm=" + name + "&n1=" + num1 + "&n2=" + num2 +
"&grt=" + nn3;
Response.Redirect(Url);
}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Result Flow Layout:

Result.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Result.aspx.cs"
Inherits="Result" %>

<!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="Label"></asp:Label>


<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>

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

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Result.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 Result : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
String name=Server.UrlDecode(Request.QueryString["nm"]);
String n1 = Server.UrlDecode(Request.QueryString["n1"]);
String n2 = Server.UrlDecode(Request.QueryString["n2"]);
String n3 = Server.UrlDecode(Request.QueryString["grt"]);

Label1.Text = "User Name: " + name;


Label2.Text = "First Number: " + n1;
Label3.Text = "Second Number: " + n2;
Label4.Text = "Gretest Number Is: " + n3;

}
}

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

10. DEVLOP A ASP.NET APPLICATION USING


i) MENU 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:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:Menu>
</div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

ii) 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>

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

iii) SITEMAP PATH CONTROL

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 :- Name:-
TYBSc(IT) Advance Web Programming

11. DEVLOP A ASP.NET APPLICATION TO CREATE MASTER PAGE WITH


THREE CONTENT PAGE.

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>

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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

MasterPage.Master.cs:

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>

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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>

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

12. Develop a ASP>NET application to insert and delete student record (RollNo,
FName, Marks, gender, Address).

Form Layout:

Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication23.WebForm1" %>

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

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

<asp:Label ID="Label1" runat="server" Text="Student Roll


Number"></asp:Label>
&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Student Name"></asp:Label>
&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Student Address"></asp:Label>
&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Submit" />
&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" onclick="Button2_Click1"
Text="Delete" />
&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button3" runat="server" onclick="Button3_Click"
Text="Update" />
&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button4" runat="server" onclick="Button4_Click"
Text="Show" />
&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button5" runat="server" onclick="Button5_Click"
Text="Display" />
<br />
<br />
<br />
<asp:Label ID="Label4" runat="server"></asp:Label>

<br />
<br />

<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<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;

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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

protected void Button1_Click(object sender, EventArgs e)


{
SqlConnection conn = new SqlConnection("Data Source=ADMIN;Initial
Catalog=sushiladevi;Integrated Security=True");
String query = "insert into degree (RollNo,FName,Address)values('" +
TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "') ";
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);
cmd.ExecuteNonQuery();
Label4.Text = "Data Submitted successfully";

TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}

catch
{
Label4.Text = "Problem in Database Connection";
}
finally
{
conn.Close();
}

protected void Button2_Click1(object sender, EventArgs e)


{
SqlConnection conn = new SqlConnection("Data Source=ADMIN;Initial
Catalog=sushiladevi;Integrated Security=True");
String query = "delete from degree where RollNo='" + TextBox1.Text +
"'";
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);
cmd.ExecuteNonQuery();
Label4.Text = "Data Deleted successfully";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

catch
{
Label4.Text = "Problem in Database Connection";
}
finally
{
conn.Close();
}
}

protected void Button3_Click(object sender, EventArgs e)


{
SqlConnection conn = new SqlConnection("Data Source=ADMIN;Initial
Catalog=sushiladevi;Integrated Security=True");
String query = "update degree set FName = ' " + TextBox2.Text + " ',
Address = ' " + TextBox3.Text + "' where RollNo = '" + TextBox1.Text + "'";
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);
cmd.ExecuteNonQuery();
Label4.Text = "Data Updated successfully";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";

}
catch
{
Label4.Text = "Problem in Database Connection";
}
finally
{
conn.Close();
}
}

protected void Button4_Click(object sender, EventArgs e)


{
SqlConnection conn = new SqlConnection("Data Source=ADMIN;Initial
Catalog=sushiladevi;Integrated Security=True");
{
String roll = TextBox1.Text;
SqlCommand cmd = new SqlCommand("SELECT FName, Address FROM
degree WHERE RollNo =" + roll);

try
{
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
conn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
TextBox2.Text = sdr["FName"].ToString();
TextBox3.Text = sdr["Address"].ToString();

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Label4.Text = "Data Showen sucessfully";


}
}
catch
{
Label4.Text = "Problem in connection or in database";
}

finally
{
conn.Close();
}

}
}

protected void Button5_Click(object sender, EventArgs e)


{
SqlDataAdapter da = null;
DataSet ds = null;
SqlConnection conn = new SqlConnection("Data Source=ADMIN;Initial
Catalog=sushiladevi;Integrated Security=True");
da = new SqlDataAdapter("Select * From degree", conn);
ds = new DataSet();
da.Fill(ds, "degree");
GridView1.DataSource = ds.Tables["degree"];
GridView1.DataBind();
}

}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

13. DEVLOP AN APPLICATION TO DEMONSTRATE THE 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"

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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>
</div>
</form>
</body>
</html>

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="width: 39px" Text="Find" />
<br />
<br />
<br />
<br />
<br />
<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();

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

da.Fill(ds);
DetailsView1.DataSource=ds;
DetailsView1.DataBind();
con.Close(); }}
Output:-

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:ListView ID="ListView1" runat="server"


DataSourceID="SqlDataSource1">
<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>

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

<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="">
<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") %>' />

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

</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">
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;">

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

14. PROGRAMS USING LINQ. GIVE SYNTAX


i. LINQ TO OBJECT
ii. LINQ TO XML
iii. LINQ TO ADO.NET

i) LINQ TO OBJECT
Default.aspx.cs:

using System;
using System.Xml.Linq;

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


{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void cmdShowAll_Click(object sender, EventArgs e)
{
XDocument document = XDocument.Load(@"C:\Books.xml");
var books = from r in document.Descendants("book")
select new
{
Author = r.Element("author").Value,
Title = r.Element("title").Value,
Price = r.Element("price").Value
};
foreach (var r in books)
{
ListBox2.Items.Add(" Title: "+ r.Title +", Author: " + r.Author+", Price: " +
r.Price);
}
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

ii) LINQ TO XML

Customers.xml:

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


<books>
<book id="bk101">
<author id="1">Balgurusamy</author>
<title>Introduction to C++</title>
<price>180</price>
</book>
<book id="bk102">
<author id="2">Kanjilal</author>
<title>ASP.NET 4.0</title>
<price>450</price>
</book>
<book id="bk103">
<author id="3">Watson</author>
<title>Visual C# 2000</title>
<price>599</price>
</book>
</books>

Default.aspx.cs;

using System;
using System.Xml.Linq;

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


{

protected void Page_Load(object sender, EventArgs e)


{

}
protected void cmdShowAll_Click(object sender, EventArgs e)
{
XDocument document = XDocument.Load(@"C:\Books.xml");
var books = from r in document.Descendants("book")
select new
{
Author = r.Element("author").Value,
Title = r.Element("title").Value,
Price = r.Element("price").Value
};

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

foreach (var r in books)


{
ListBox2.Items.Add(" Title: "+ r.Title +", Author: " + r.Author+", Price: "
+ r.Price);
}
}
}

Output:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

15. DEVELOP ASP.NET APPLICATION TO DEMONSTRATE FOLLOWING AJAX


CONTROLS.
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" %>

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

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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


{
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:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

ii) TIMER CONTROL:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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>
</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)
{

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

protected void click(object sender, EventArgs e)


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

Output:

iii) UpdateProgress Control:


Default.aspx:

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

<%@ Page Language="C#" AutoEventWireup="true"


CodeFile="Default2.aspx.cs" Inherits="Default2" %>

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

Roll No :- Name:-
TYBSc(IT) Advance Web Programming

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


{
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 :- Name:-
TYBSc(IT) Advance Web Programming

Roll No :- Name:-

You might also like