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

Web Tech

The document is a lab manual for a Web Technology course that provides a list of programming exercises for students. It includes 22 exercises divided into Script Programs and ASP Programs sections. The exercises cover topics like simple calculations, sorting data, validation, and manipulating databases. For each exercise, it lists the aim, algorithm, source code, output and result. This lab manual aims to help students learn and practice various web programming concepts through hands-on exercises.

Uploaded by

Jayashree
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)
320 views

Web Tech

The document is a lab manual for a Web Technology course that provides a list of programming exercises for students. It includes 22 exercises divided into Script Programs and ASP Programs sections. The exercises cover topics like simple calculations, sorting data, validation, and manipulating databases. For each exercise, it lists the aim, algorithm, source code, output and result. This lab manual aims to help students learn and practice various web programming concepts through hands-on exercises.

Uploaded by

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

CHEVALIER T.

THOMAS ELIZABETH COLLEGE FOR WOMEN

Department of Computer Science

YEAR: III SEMESTER: VI

MADRAS UNIVERSITY
WEB TECHNOLOGY

LAB MANUAL
SI.NO. NAME OF THE PROGRAM PAGE NO.

SCRIPT PROGRAMS
Squares, Roots, Cubes & Complements of Integers Between
1
1 To 100
2 Simple Calculator
3 Sorting Numbers And Strings
4 Hit Counter
5 E-Mail Address Validation
6 Scrolling Text On Status Bar
7 Using Mutliple And Single Choice List
8 Digital Clock
9 Switching Images Using Mouse Events
10 Swapping Images
11 Using Frames Set Tags
12 Employee Database Validation

ASP PROGRAMS

13 Login Forms
14 Manipulation Of Employee Database
15 Usage Of Request And Response Object
16 Getting The Exact List of Headers Using Request Object
17 Manipulation Of Student Database
18 Online BookShop
19 Using OnMouseOver For a Hyperlink
20 Loading and Unloading a User Defined Page
21 Cookies
SCRIPT
PROGRAMS

EX.NO.1 SQUARE, SQUARE ROOT, CUBES AND COMPONENTS OF INTEGER


BETWEEN 1 TO 100

AIM:
To write a simple HTML program for calculating Squares, Roots, Cubes, and
Components for an integer between 1 and 100 by writing “Javascript”.

ALGORITHM:

Step 1: Create a new file as MATH.html.


Step 2: Give the title for the pages as MATH operations by using <Title> tag.
Step 3: In the body section, mention script language as “JavaScript” using <Script> tag.
Step 4: Declare the variable i,a=9,b=99,c=999,d;
Step 5: User will enter the number between 1 to 100 using <prompt> tag and store it in i.
Step 6: Find the square of the value I and display the result using document.write();
Step 7 Find the Square root value of the i using MATH.sqrt() function and display using
document.write()
Step 8: Find the cube of i using MATH.pow() and display using document.write()
Step 9: If the value of (i<=a) then find the 9’s complement of ‘i’  (a-i) and display it using
document.write()
Step 9.1: Find the 9’s complement of i((a-i)+1) and store it in ‘d’. Display ‘d’ using
document.write()
Step 10: ElseIf ((i>=10) && (i<=99)) now find the 9’s complement of i  (b-i) display it
using document.write()
Step 10.1:Now the 10’s complement of (i (b-i)+1) and store it in’d’. Display it using
document.write()
Step 11: ElseIf (i==100) now find the 9’s complement of i (c-i) and display it using
document.write()
Step 11.1: Find the 10’s complement of i (c+i) +1 and store it in d, display it using
document.write()
Step 12: End </script> </body> tag.
Step 13: Save the program and see the web page in the Internet Explorer.

SOURCE CODE:
<html>
<meta http-equiv="x-ua-compatible"content="IE=10">
<head>
<title>MATH OPERATION</title></head>
<body>
<h2><b><center><u>Square root,Cube and Complement</h2></b></u></center>
<script language="Javascript">
var i,a=9,b=99,c=999,d;
i=prompt("enter the no between 1&100:");
document.write("<h3><centre><br/><br/>the square of"+i+"is="+(i*i));
document.write("<br/><br/>the square root of"+i+"is="+Math.sqrt(i));
document.write("<br/><br/>the cube of"+i+"is="+Math.pow(i,3));
if(i<=9)
{
document.write("<br/><br/>the 9's complement of"+i+"is="+(a-i));
d=parseInt((a-i)+1);
document.write("<br/><br/>the 10's complement of"+i+"is="+d);
}
else if((i>=10)&&(i<=99))
{
document.write("<br/><br/>the 9's complement of"+i+"is="+(b-i));
d=parseInt((b-i)+1);
document.write("<br/><br/>the 10's complement of"+i+"is="+d);
}
else if(i==100)
{
document.write("<br/><br/>the 9's complement of"+i+"is="+(c-i));
d=parseInt((c-i)+1);
document.write("<br/><br/>the 10's complement of"+i+"is="+d);
}
</script>
</body>
</html>
OUTPUT:

SQUARES,SQUARE ROOTS,CUBES AND COMPLEMENTS

CONCLUSION:
Thus, the Java Script program for displaying Square, Roots, Cubes and Complements for
an Integer has been executed successfully.
EX.NO:2 SIMPLE CALCULATOR

AIM:

To write a simple HTML program to design a SIMPLE CALCULATOR “Javascript”.

ALGORITHM:

Step 1: Create a file name as Calc.html


Step 2: Set a Script language as “JavaScript”
Step 3: In the body part, create a form named as calc.
Step 4: Create table with border size of four
Step 5: Create text box as ‘Input’ in first row of the table.
Step 6: Create buttons from 0 to 9 numbers in their onclick concatenate the number which is
already in text box ‘Input’
Step 7: Create ‘-‘ button and call min() to place the ( - ) in the textbox.
Step 7.1: Create ‘+’ button and call pl() to place the ( + ) sign in the textbox
Step 8: Create ‘ *’ button and call mul() function to place the ( * ) sign in the textbox
Step 9: Create ‘clr’ button and call clearing() function to clear the textbox.
Step 10: Create ‘=’ button and call eql() function to evaluate the given expression in the textbox.
Step 11: Create ‘ / ‘ button and call div1() function to place the ( / )sign in the textbox.
Step 12: Create sin,cos,tan & pow button to get the result of these functions using the ‘MATH’ object
separately by calling sin1,cos1,tan1,power function in onclick on them.
Step 13: Save the file, execute it in Internet Explorer.

SOURCE CODE:
<!--- SIMPLE CALCULATOR --->

<html>
<head> <title> Simple Calculator </title>
<style>
#b
{
width=60px;
height=30px;
}
</style>
<script language="Javascript">
var str,status=0;
function eql(form)
{
if(status==1)
{
str=calc.input.value;
x=str.split('pow');
calc.input.value=Math.pow(parseInt(x[0]),parseInt(x[1]));
}
else
calc.input.value=eval(calc.input.value);
}
function pl(form)
{
calc.input.value+='+';
status=0;
}
function min(form)
{
calc.input.value+='-';
status=0;
}
function mul(form)
{
calc.input.value+='*';
status=0;
}
function div1(form)
{
calc.input.value+='/';
status=0;
}
function clearing(form)
{
calc.input.value=' ';
}
function sin1(form)
{
calc.input.value=Math.sin(parseInt(calc.input.value));
}
function cos1(form)
{
calc.input.value=Math.cos(parseInt(calc.input.value));
}

function tan1(form)
{
calc.input.value=Math.tan(parseInt(calc.input.value));
}
function power(form)
{
calc.input.value+='pow';
status=1;
}
</script> </head>
<body bgcolor="pink">
<br/> <br/> <br/> <br/> <br/>
<font size="20">
<center> <h1>
Simple calculator
</center> </h1>
<center> <br/>
<form name="calc">
<table border="4">
<tr> <td>
<input type="text" name="input" size="38"/>
</tr> </td>
<tr> <td>
<input type="button"id="b"name="one"value="1"onClick="calc.input.value+='1'"/>
<input type="button"id="b"name="two"value="2"onClick="calc.input.value+='2'"/>
<input type="button"id="b"name="three"value="3"onClick="calc.input.value+='3'"/>
<input type="button"id="b"name="plus"value="+"onClick="pl(this.form);"/>
</tr></td>
<tr> <td>
<input type="button"id="b"name="four"value="4"onClick="calc.input.value+='4'"/>
<input type="button"id="b"name="five"value="5"onClick="calc.input.value+='5'"/>
<input type="button"id="b"name="six"value="6"onClick="calc.input.value+='6'"/>
<input type="button"id="b"name="minus"value="-" onClick="min(this.form);"/>
</td> </tr>
<tr> <td>
<input type="button"id="b"name="seven"value="7"onClick="calc.input.value+='7'"/>
<input type="button"id="b"name="eight"value="8"onClick="calc.input.value+='8'"/>
<input type="button"id="b"name="nine"value="9"onClick="calc.input.value+='9'"/>
<input type="button"id="b"name="multi"value="*"onClick="mul(this.form);"/>
</td> </tr>
<tr> <td>
<input type="button"id="b"name="clear"value="clr"onClick="clearing(this.form);"/>
<input type="button"id="b"name="equal"value="="onClick="eql(this.form);"/>
<input type="button"id="b"name="zero"value="0"onClick="calc.input.value+='0' "/>
<input type="button"id="b"name="div"value="/"onClick="div1(this.form);"/>
</tr> </td>
<tr> <td>
<input type="button"id="b"name="sin"value="sin"onClick="sin1(this.form);"/>
<input type="button"id="b"name="cos"value="cos"onClick="cos1(this.form);"/>
<input type="button"id="b"name="tan"value="tan"onClick="tan1(this.form);"/>
<input type="button"id="b"name="pow"value="pow"onClick="power(this.form);"/>
</td> </tr>
</table>
</center>
</font>
</form>
</body>
</html>

OUTPUT:

SIMPLE CALCULATOR
RESULT:

Thus the Simple Calculator program in JavaScript has been generated and executed
successfully.
EX:NO:3 SORTING NUMBERS AND STRINGS

AIM:

To write a simple HTML program for SORTING numbers and strings using arrays in “Javascript”.

ALGORITHM:

Step 1: Create a file as sort.html.


Step 2: Set title as sorting array elements.
Step 3: Assign the script language as “ JavaScript “
Step 4: Create two array variable arr[] and brr[]
Step 5: In prompt dialogue box get the value of ‘n’
Step 6 : Initialize the control variable ‘i’ by 0 till ’n’ and read the integer in the array arr.
Step 7: Initialise the control variable ‘j’ by 0 till ‘n’ and read the string in the array brr.
Step 8 : Print the array elements arr and brr, sort the integer array elements using arr.sort() function
Step 9 : Sort the string array elements using brr.sort() function
Step 10 : Save the program as sort.html and see the web page in Internet Explorer

SOURCE CODE:

<html>
<meta http-equiv="x-ua-compatible"content="IE=10">
<head>
<title> Sorting Array Elements
</title> </head>
<body>
<script language="javascript">
var n,i,j,temp,m;
arr=new Array(15);
brr=new Array(15);
n=prompt("Enter the value of n","n");
for(i=0;i<n;i++)
arr[i]=parseInt(prompt("enter the integer"));
for(j=0;j<n;j++)
brr[j]=prompt("enter the string");

//numbers sorting

document.write("<u><h1> Sorting Array Elements</h1><br/></u>");


document.write("<u><h1> Sorting Numbers</h1><br/> <h3> Before sorting </h3></u>");
for(i=0;i<n;i++)
document.write("<h4>"+arr[i]+"</h4>");
document.write("<b><h3>Sorted using sort() method </b></h3>");
arr.sort();
document.write("<b><u><h3>After sorting</b></u></h3>");
for(i=0;i<n;i++)
document.write("<h4><br/>"+arr[i]+"</h4>");

//string sorting
document.write("<u><h1> Sorting Strings</h1><br/> <h3> Before sorting </h3></u>");
for(j=0;j<n;j++)
document.write("<h4>"+brr[j]+"</h4>");
document.write("<b><h3>Sorted using sort() method </b></h3>");
brr.sort();
document.write("<b><u><h3>After sorting</b></u></h3>");
for(j=0;j<n;j++)
document.write("<h4><br/>"+brr[j]+"</h4>");
</script> </body> </html>

OUTPUT:

SORTING NUMBERS AND STRINGS


RESULT
Thus, the program for sorting integer and strings using JavaScript has been executed
successfully.
EX:NO:4 HIT COUNTER

AIM:
To create a simple html program to generate hit counter by using “JavaScript”.

ALGORITHM:

Step1: Create file name as “hitcounter.html”


Step 2: Assign script language as “JavaScript”
Step 3: Call InsertCounter() function in the <body> tag
Step 3.1: In the InsertCounter() function we have called readcookie() and displaycounter().
Step 3.1.1: In the reascookie() function, declare cookie and set counter as also
Step 3.1.2: Declare the result i , chrn.
Step 3.1.3: Initialize nvpair=chkd cookie split (“;”); Arguments need as ckie, nme
Step 3.1.4: And then assign counter to get a value for nvpair and pagecount & call the function
getcookievalue
Step 3.1.4.1: In the function getcookievalue() pause the argument ckie, nme. Declare the variable as
splitvalue and i.
Step 3.1.4.2: If the length of the ckie is less than ‘ie’ assign the variable splitvalue as cookie[i].split(“=”);
and if splitvalue= nme means return value [i]
Step 3.1.5: Assign the variable futdate and expdate and assign the expdate as 3600000*24*30 to use
setTimeOut.
Step 3.1.6: In displaycounter() function if the counter =1 means print the text as “you have visited this
page the first time”.
Step 3.1.7: Else print the number of time by using countervariable
Step 3.1.8: save and execute the file in Internet Explorer.

SOURCE CODE:
//HIT COUNTER USING JAVASCRIPT

<html>
<head>
<script language="javascript">
<!--
function nameDefined(ckie,nme)
{
var splitValues;
var i;
for(i=0;i<ckie.length;++i)
{
splitValues=ckie[i].split("=");
if(splitValues[0]==nme)
return true;
}
return false;
}
function delBlanks(strng)
{
var result="";
var i;
var chrn;
for(i=0;i<strng.length;++i)
{
chrn=strng.charAt(i);
if(chrn!=" ")
result +=chrn;
}
return result;
}
function getCookieValue(ckie,nme)
{
var splitValues;
var i;
for(i=0;i<ckie.length;++i)
{
splitValues=ckie[i].split("=");
if(splitValues[0]==nme)
return splitValues[1];
}
return "";
}
function insertcounter()
{
readcookie();
displaycounter();
}
function displaycounter()
{
document.write('<h3 ALIGN="CENTER">');
document.write("You have Visited this page");
if(counter==1)
document.write(" The First Time.");
else
document.write(counter += " TIMES.");
document.write('</h3>');
}
function readcookie()
{
var cookie=document.cookie;
counter=0;
var chkdCookie=delBlanks(cookie);
var nvpair=chkdCookie.split(";");
if(nameDefined(nvpair,"pageCount"))
{
counter=parseInt(getCookieValue(nvpair,"pageCount"));
}
++counter;
var futdate=new Date();
var expdate=futdate.getTime();
expdate+=3600000*24*30;
futdate.setTime(expdate);
var newCookie="pageCount = "+counter;
newCookie+= "; expires="+futdate.toGMTString();
window.document.cookie=newCookie;
}
//-->
</script>
</head>
<body>
<script language="javascript">
<!--
insertcounter();
//-->
</script>
</body>
</html>
OUTPUT:

HIT COUNTER

RESULT:

Thus, the hit counter program in JavaScript has been generated and executed
successfully.
EX:NO:5 EMAIL ADDRESS VALIDATION

AIM:

To create a simple HTML program for validating the Email ID by the user.

ALGORITHM:

Step 1:create a file name as email html

Step 2: set title as Email ID validation and script language as “javascript”

Step 3:declare the variable str, state, state1=0

Step 3-1: get the email ID from the user using prompt tag and store it in str variable

Step 3-2:print the given email ID

Step 4:split the str string into two parts with @ by writing split function: first part will be stored
in user[0],second part will be stored in user[1]

Step 4-1: In chk state, check whether the first part user [0] has all its characters as numbers or
alphabets or underscore, using unicode values in for loops

Step 4-2: If true for all characters assign state=1, else state=0 break the chk state

Step 4-3: check if (state ==1 && state ==1)

Domain= user[1] split (“.”);

Step 4-4: print “valid email ID" else print “Invalid email ID"

Step 5: save the file and execute in Internet explorer.

SOURCE CODE:
<!--EmailID Validation-->

<html>
<meta http-equiv="x-ua-compatible"content="IE=10">
<head>
<title>
Email-id validation</title>
<script language="Javascript">
function check()
{
var str;
var state=0;
var state1=0;
str=prompt("Enter ur E-mail ID");
document.write("<h1><b><center>E-mail ID Validation</center></b></h1>");
document.write("<b><center>E-mail Id:"+str+"</b></center>");
var user=str.split("@");
chkstate:
for(i=0;i<user[0].length;i++)
{
if((user[0].charCodeAt(i)>96 && user[0].charCodeAt(i)<123)
||(user[0].charCodeAt(i)>64 && user[0].charCodeAt(i)<91)
||(user[0].charCodeAt(i)>47 && user[0].charCodeAt(i)<58)
||(user[0].charCodeAt(i)==95 ))
state=1;
else
{
state=0;
break chkstate;
}
}
chkstate1:
for(i=0;i<user[1].length;i++)
{
if((user[1].charCodeAt(i)>96 && user[1].charCodeAt(i)<123)
||(user[1].charCodeAt(i)>64 && user[1].charCodeAt(i)<91)
||(user[1].charCodeAt(i)>47 && user[1].charCodeAt(i)<58)
||(user[1].charCodeAt(i)==64 )||(user[1].charCodeAt(i)==46))
state1=1;
else
{
state1=0;
break chkstate1;
}
}
if(state==1 && state1==1)
{
var domain=user[1].split(".");
if(domain[1].length==0||domain[1].length>4)
alert("Invalid Email Id");
else
alert("valid Email Id");
}
else
alert("Invalid Email Id"); }
</script> </head>
<body onLoad="check()">
</body> </html>

OUTPUT:

E-Mail ID Validation
RESULT:

Thus, the Email ID using java script has been generated and executed successfully.
EX:NO:6 SCROLLING TEXT ON STATUS BAR

AIM:
To write a simple html program for scrolling text in the statusbar of the web page using
“JavaScript”.

ALGORITHM:

Step 1: Create a new file name “status.html”.


Step 2: Assign script language as “JavaScript”.
Step 3: Create a style sheet with font:10pt Arial;
Step 4: Create a variable barmsg and assign the value “WELCOME TO MY PAGE”.
Step 5: Create a variable i and assign the value i = 0.
Step 6: Assign the variable beginning part as beginingpart=barmsg.substr(I,barmsg.length);
Step 7: Assign endpart=barmsg.substr(0,i).
Step 8: Assign window.state=beginningpart+endpart. This will display the scrolling text in statusbar.
Step 9: Check if(i<barmsg.length) if true i++; else assign i=0;
Step 10: Then setTimeOut(“scrollmsg()”,300);
Step 11: Call the function scrollmsg() onLoad of the body.
Step 12: We can see the scrolltext in the statusbar in the webpage.
Step 13: Save the program and see the webpage in the Internet Explorer.

SOURCE CODE:
<!--SCROLLING TEXT ON STATUS BAR-->

<html>
<head>
<style>
.text
{
font:14 pt arial;
color:red;
}
</style>
<script language="javascript">
barmsg="welcome to my page";
i=0;
function scrollmsg()
{
beginningpart=barmsg.substr(i,barmsg.length);
endpart=barmsg.substr(0,i);
window.status=beginningpart+endpart;
if(i<barmsg.length)
{
i++;
}
else
{
i=0;
}
setTimeout("scrollmsg()",300)
}
</script>
</head>
<body onLoad="scrollmsg()" bgcolor="pink">
<br><br><br> <center>
<font class=text> <h1> <u>scrolling text in status bar</u> </h1> <br>
<h3>Look at the Status Bar in the botton left of your webpage.....</h3>
</center>
</body>
</html>

OUTPUT:

SCROLLING TEXT IN STATUS BAR

RESULT:
Thus, the program for Scrolling Text in the Statusbar using JavaScript has been executed
successfully.
EX:NO:7 MULTIPLE, SINGLE CHOICE LIST

AIM:

To write a html program for a form that consists of multiple choice list and single choice list
using VBscript.

ALGORITHM:

Step 1: Create a new file name “list.html”.


Step 2: Assign script language as “VBscript”.
Step 3: Assign a variable as lot=0.
Step 4: Place the following controls
LABELS: To display the caption.
SELECT : To display the list of maindish, starters and milkshakes.
TEXTAREA: To display the total bill amount.
BUTTON: To display the total bill amunt.
Step 5: Function maindish()
Makes the selected maindish to be seen in the textarea
Extract price from the maindish as the last 3 characters and add it as lot.
Step 6: Function starters(), milkshake()
Make the selected choice items to be displayed in the text area from the 2 choice list.
Step 7: Function bill()
Display the bill amount(lot) using the msgbox.
Step 8: Link the function appropriately to the controls, choice list, button.
Step 9: Execute the program in the Internet Explorer.

SOURCE CODE:

<head>
<meta http-equiv="x-ua-compatible" content="IE=10">
<script language="vbscript">
dim i,tot
tot=0
sub maindish()
i=f1.s1.selectedIndex
for i=0 to 3
if f1.s1.options(i).selected then
f1.ta1.value=f1.ta1.value+vbcrlf+f1.s1.options(i).text
tot=tot+cint(right(f1.s1.options(i).value,3))
end if
next
end sub
sub starters()
i=f1.s2.selectedIndex
f1.ta1.value=f1.ta1.value+vbtab+f1.s2.options(i).text
end sub
sub milkshake()
i=f1.s3.selectedIndex
f1.ta1.value=f1.ta1.value+vbtab+f1.s3.options(i).text
end sub
sub bill()
msgbox"you have to pay:is" &Cstr(tot)
end sub
</script>
</head>
<body>
<form name="f1">
<br> <br> <br>
<center> <b> <br> <u>SAMPLE MENUCARD</u> </b> </center> <br> <br>
<input type="label" name="label1" value="maindish" >
<select name="s1" onChange="maindish()" MULTIPLE >
<option value="mcburger->100"> mcburger </option>
<option value="fishfillets->120"> fishfillets </option>
<option value="chickenburger->140"> chickenburger </option>
<option value="vegburger->130"> vegburger </option>
</select> <br> <br>
<input type="label" name="label2" value="starters">
<select name="s2" onChange="starters()">
<option> frenchfries </option>
<option> nuggets </option>
<option> hashbrowns </option>
<option> mcalooticks </option>
</select> <br> <br>
<input type="label" name="label3" value="misc">
<select name="s3" onChange="milkshake()">
<option> milkshake </option>
<option> softdrinks </option>
<option> softy </option>
<option> cooldrinks </option>
</select> <br> <br>
<textarea name="ta1" rows="10" cols="50">
</textarea> <br> <br> <br>
<input type="button" name="button1" value="bill" onClick="bill()">
</form>
</body>
</html>

OUTPUT:

USING MULTIPLE AND SINGLE CHOICE LIST


RESULT:

Thus, the choice list program in the VBscript has been created and generated
successfully.
EX:NO:8 DIGITAL CLOCK

AIM:

To write a simple HTML program using VBscript for displaying a digital clock in
webpage.

ALGORITHM:

Step 1: Create a file name digital.html


Step 2: Set script language as VBscript.
Step 3: Declare variable dt,h,m,s,h1,m1,s1.
Step 4: Declare a procedure digital().
Step 4.1: Check if(h<10),if true h1=’0’ & cstr(h).
Step 4.2: Else h1=cstr(h)
Step 4.3: Check if (m<10), if true m1=’0’ & cstr(m)
Step 4.4: Else m1=cstr(m).
Step 4.5: Check if (S<10), if true s1=’0’ & cstr(s).
Step 4.6: Else s1=cstr(s).
Step 4.7: Check if(h>12), if true s1=s1 + “AM”.
Step 4.8: Else s1=s1 + “PM”.
Step 5: The procedure digital() is repeated by executing for every thousand millisecond using the
statement. SetTimeOut = “didgital()”,1000
Step 6: Call the function digital() section on the load event of the body section display the text
“Digital Clock” in the body section of the webpage
Step 6.1: Create a label box name = label1 and display the text “WELCOME” which will show
time later.
Step 7: Save the file and execute in Internet Explorer.

SOURCE CODE:
<!-- Digital Clock using Javascript-->

<html>
<head>
<script language="Javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
ap=checkAmPm(h);
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML="<center><h3>"
+h+":"+m+":"+s+":"+ap+"</center></h3>";
t=setTimeout('startTime()',1000);
}
function checkTime(i)
{
if(i<10)
i="0"+i;
return i
}
function checkAmPm(i)
{
if(i>=12)
i="Pm";
else
i="Am";
return i
}
</script>
</head>
<body onLoad="startTime()"bgcolor="yellow">
<br/><br/>
<center><h1>Digital Clock</h1></center>
<br/>
<center><div id="txt"></div>
</center>
</body>
</html>
OUTPUT:

DIGITAL CLOCK USING JAVASCRIPT

SOURCE CODE:
<!-- Digital Clock using VBscript-->

<html>
<meta http-equiv="x-ua-compatible"content="IE=10">
<head>
<script language="vbscript">
dim dt
dim h,m,s,h1,m1,s1
function digital( )
dt=time
h=hour(dt)
m=minute(dt)
s=second(dt)
if (h<10) then
h1="0"&cstr(h)
else
h1=cstr(h)
end if
if (m<10) then
m1="0"&cstr(m)
else
m1=cstr(m)
end if
if (s<10) then
s1="0"&cstr(s)
else
s1=cstr(s)
end if
if (h<12) then
s1=s1+"AM"
else
s1=s1+"PM"
end if
document.getElementById("label1").Innertext=cstr(h1)&":"&cstr(m1)&":"&cstr(s1)
setTimeout"digital( )",1000
end function
</script>
</head>
<body onLoad="digital( )"bgcolor="pink">
<b><br><center><u>Digital Clock</u></b><br><br><br><br>
<input type="label" id="label1" value="WELCOME"></center>
</body>
</html>
OUTPUT:

DIGITAL CLOCK USING VB SCRIPT

RESULT:
Thus the Digital Clock program in VBscript has been generated and executed
successfully.
EX:NO:9 SWITCHING IMAGES USING MOUSE EVENTS

AIM:

To write a simple HTML program to design a webpage for switching between three images using
VBscript

ALGORITHM:

Step 1: Create a file name as “image.html”.


Step 2: Set the title as “SWITCHING IMAGES”.
Step 3: Assign script language as “vbscript”.
Step 4: In the body part load an image using <img> tag with src=”E:\3bca\Winter.jpg”.
Step 4.1: Create a button name “WAterlily” and call BtnOne() function in the onClick() event.
Step 5: When the button is clicked, the image src = “E:\3bca\Waterlily.jpg” will be displayed.
Step 6: Create a button name ‘Sunset’ and call BtnTwo() function in the onClick() event.
Step 6.1: When the button is clicked the image in src=”E:\3bca\Sunset.jpg” will be displayed.
Step 7: Create a button named “Bluehills” and call BtnThree() in onClick() event.
Step 7.1: When the button is clicked the image in src = E:\3bca\Bluehills.jpg” will be displayed.
Step 8: Save the file and execute it in Internet Explorer.

SOURCE CODE:

<----SWTICHING IMAGES---->
<html>
<head> <title> SWITCHING IMAGES </title>
<meta http-equiv="x-ua-compatible" content="IE=10">
<script language="vbscript">
function Btn1()
document.img1.src="e:\faranaa\pic1.JPG"
end function
function Btn2()
document.img1.src="e:\faranaa\pic2.BMP"
end function
function Btn3()
document.img1.src="e:\faranaa\pic3.BMP"
end function
</script>
</head>
<body> <center> <br> <br> <br> <u> <h1> SWITCHING IMAGES </h1> </u> </b>
<img src="pic4.JPG" name="img1" height=300 width=300> <br> <br>
<input type="button" name="button1" value="flower" onClick="Btn1()">
<input type="button" name="button2" value="tower" onClick="Btn2()">
<input type="button" name="button3" value="beach" onClick="Btn3()">
</center>
</body>
</html>

OUTPUT:

SWICHING IMAGES
RESULT:

Thus, the Switching Images program using VBScript has been generated and executed
successfully.
EX:NO:10 SWAPPING IMAGES

AIM:

To write a simple HTML program for swapping two images in the onmouseOver, onmouseOut,
on, ondoubleclick as event using VBscript.

ALGORITHM:

Step 1: Create a file name as “mouseevent.hml”


Step 2: Set title as “onMouseOver”, “onMouseOut”, “ondoubleclick” event.
Step 3: Set script language as “VBscript”.
Step 4: Load two images ‘Image1’ , ‘Image2’ and a button to the webpage.
Step 5: Set name = “Image1”, src = “ D:\3bca\sunset.jpg” in img tag.
Step 5.1: onmouseOver event and call image switchoff() in onmouseOut event.
Step 6: Set name = “ Image2” , src = “D;\3bca\winted.jpg” in image tag.
Step 6.1: In the function switchon() and switchoff() write a code that will interchange two loaded
images.
Step 7: Place the button and “click” which will display the description of the image that are seen
in the webpage when it is clicked using the function “content()”.
Step 8: Save the file and execute in Internet Explorer.

SOURCE CODE:

<html>
<head><meta http-equiv="x-ua-compatible" content="IE=10">
<title>using onMouseOver,onMouseEvent,onDoubleClientEvent</title>
<script language="vbscript">
function imgSwitchOn()
document.img1.src="D:\divitha\bird.jpg"
document.img2.src="D:\divitha\rose.jpg"
end function
function imgSwitchOff()
document.img1.src="D:\divitha\rose.jpg"
document.img2.src="D:\divitha\bird.jpg"
end function
function content()
document.write("<h4> Image1 <br> Filename:Colour Images <br> type:jpg Image <br> </h4> <h4>
Image2 <br> Filename:Color Image <br> type:jpg Image</h4>")
end function
</script>
</head>
<body> <center> <h2> <u>swapping images using onMouseOver,onMouseEvent,onDoubleClickEvent
</u> </h2> <br>
<h2> <i> <b> place your mouse pointer on the picture </b> </i> </h2>
<a onMouseOver="imgSwitchOn()" onMouseOut="imgSwitchOff()">
<img alt="bird" height="170" width="170" name="img1"src="bird.jpg"></a>
<a onMouseOver="imgSwitchOn()" onMouseOut="imgSwitchOff()">
<img Alt="rose" height="170" width="170" name="img2" src="rose.jpg"></a>
<br><br><br>
<input type="button" id="b1" value="double click here to view image details" ondblClick="content()">
</center>
</body>
</html>

OUTPUT:

SWAPPING IMAGES
RESULT:

Thus, the Swapping Image program in VBScript has been generated and executed
successfully.
EX:NO:11 USING FRAMES SET TAGS

AIM:

To write a HTML program to design a webpage with frameset with two frames side by side using
VBscript.

ALGORITHM:

Step 1: Create a file name as “main.html”.


Step 2: Using frame tag divide the webpage into 2 columns with name first and second, which
will display ‘first.html’ and ‘second.html’ respectively. Using the frame src = “first.html”.
Step 3: Load the file “second.html” using the tag frame src = “second.html”.
Step 4: In first.html assign script language as VBscript.
Step 4.1: In body part set bgcolor as pink and crate these radio button as yahoo, altavista and
infoseek.
Step 4.2: When the user select the yahoo radio button it calls the function onclick() which is turn
open another file called “yahoo.html” that display the details about yahoo in the 2nd
frame.
Step 4.3: When the user select the altavista radio button it calls the function onclick() which is turn
open another file called “altavista.html” that display the details about altavista in the 2nd
frame.
Step 4.4: When the user select the infoseek radio button it calls the function onclick() which is turn
open another file called “infoseek.html” that display the details about infoseek in the 2nd
frame
Step 5: In “second.html” set the body part with bgcolor=”Aqua” and displays the heading as
webpage.
Step 6: Save the file and execute “main.html” program in Internet Explorer.

SOURCE CODE:

<!--Main.html-->
<html>
<frameset cols="50%,*">
<frame src="first.html" name="first">
<frame src="second.html" name="second">
</frameset>
</html>

<!--first.html-->
<html>
<script language="vbscript">
sub radioclk1()
top.second.document.location.href="D:\wt\yahoo.html"
end sub
sub radioclk2()
top.second.document.location.href="D:\wt\infoseek.html"
end sub
sub radioclk3()
top.second.document.location.href="D:\wt\altavista.html"
end sub
</script>
<body bgcolor="pink">
<font face="Times New Roman" size="6"><u><center>
Select A Web Page </u></center></font>
<font face="Times New Roman" size="5"> <br><br>
<input type="radio" name="r1" text="Yahoo" onclick="radioclk1()">
Yahoo <br><br>
<input type="radio" name="r1" text="Infoseek" onclick="radioclk2()">
Infoseek <br><br>
<input type="radio" name="r1" text="Altavista" onclick="radioclk3()">
Altavista <br><br>
</font>
</body>
</html>

<!--second.html-->
<html>
<body bgcolor="aqua">
<font face="Times New Roman" size="6">
<u><center>WEB PAGE</center></u>
</font> </body> <html>

<!--infoseek.html-->
<html>
<body bgcolor="aqua">
<font face="Times New Roman" size="7"><u><center>
Welcome to Infoseek Web Page </u></center></font>
<font face="Times New Roman" size="5">
&nbsp;&nbsp;&nbsp;&nbsp;<br>
<ol>
<li> Infoseek was a very popular search engine founded in
1994 by Steve Kirsch.
<li>Infoseek was originally operated by
Infoseek corparation,headquarted in sunnyvale,california.
<li>Infoseek featured a very complex system of search modifiers,
including boolean modifiers such as the most basic "OR"and
"NOT",parentheses and quotes upto being able to say that
one wanted one word or phrase,to appear within X number
of words from another word or phrase
</ol>
</font> </body> </html>

<!--altavista.html-->
<html>
<body bgcolor="aqua" >
<font face="Times New Roman" size="7"><u><center>
Welcome to Altavista Web Page </u></center></font>
<font face="Times New Roman" size="5">
&nbsp;&nbsp;&nbsp;&nbsp;<br>
<ul>
<li> Altavista is a web search engine owned by Yahoo!
Altavista was once one of the most popular search
engines but its popularity declined with rise of Google.
<li>Yahoo plans on discontinouing Altavista,as it is underperforming
Altavista was created by researches at Digital equipment
corporations Western Research Labrotary who were trying
to make finding files on public network easier.
<li>Altavista was publicly launched as an Internet search engine
on 15 Dec 1995 at Altavista.digital.com.
</ul>
</font> </body> </html>

<!--yahoo.html-->
<html>
<body bgcolor="aqua">
<font face="Times New Roman" size="7"><u><center>
Welcome to Yahoo Web Page </u></center></font>
<font face="Times New Roman" size="5">
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp&nbsp;&nbspYahoo is an American public
corporation with headquaters in
sunnyvale,california,that provide services via internet worldwide.
Yahoo was founded by Jerry Yang and David Filo in Jan1994
and was incorparated on Mar1 1995.
&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp&nbsp;&nbspThe
company is perhaps best known for its web portal,
search engine(Yahoo search),Yahoo! Directory,Yahoo Mail,
Yahoo! News,advertising,Online mapping(Yahoo! maps),
video sharing(Yahoo! video) and social media websites and services.
</font> </body> </html>
OUTPUT:

USING FRAMESET TAGS


RESULT:
Thus, the Frameset program in VBScript has been generated and executed successfully.
EX:NO:12 EMPLOYEE DATABASE VALIDATION

AIM:

To write a simple HTML program to design a webpage for calculating ‘Paybill’ using employee
database and VBscript.

ALGORITHM:

Step 1: Create a new file named as “Employee.html”


Step 2: Set script language as “VBscript”.
Step 3: Set the variable objconn as set objconn = create object(“ADODB connection”) to connect
the database.
Step 4: Set the variable object as set object = create object(“ADODB connection”) to retrieve the
records from the database.
Step 5: Using the connection object objconn / open the database using objconn.open
”Provider=Microsoft.Jet.OLEDB.4.0”;
Step 6: Assign the strSQL with SQL statement as strSQL=”select * from table1” to access the
data.
Step 7: In the body create a form with form name=”EmpForm”.
Step 8: Place the textbox, combobox for setting the input from the user.
Step 9: Create “clear form” button which call “clear()” function to clear the const of the form.
Step 10: Create “calculate pay” button which call “process()” to calculate the salary.
Step 11: Create “search” button which call “search()” to particular employee details.
Step 12: Create “New” button which call “new()” function.
Step 13: Create “Edit and Update” button which calls “update()” function and update record
details to the database.
Step 14: Create “Next” button which calls navigate function to move and save.
Step 15: Save the file and execute using “Internet Explorer”.

SOURCE CODE:

<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=10">
<script language="vbscript">
Const adLockOptimistic=3
Const adUseClient=3
dim i,id,ch
dim objconn,objrs,strsql

set objconn=CreateObject("ADODB.Connection")
set objrs=CreateObject("ADODB.Recordset")
objconn.Open"provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Anusuya.A\employee1.mdb;"
strsql="select * from emp"

sub designation()
i=EmpForm.d1.selectedIndex
EmpForm.Text21.value=EmpForm.d1.options(i).Text
select Case i
Case 0:EmpForm.Text3.value=20000
EmpForm.Text4.value=Cint(EmpForm.Text3.value)*20/100
EmpForm.Text5.value=Cint(EmpForm.Text3.value)*15/100
Case 1:EmpForm.Text3.value=15000
EmpForm.Text4.value=Cint(EmpForm.Text3.value)*10/100
EmpForm.Text5.value=Cint(EmpForm.Text3.value)*8/100
Case 2:EmpForm.Text3.value=10000
EmpForm.Text4.value=Cint(EmpForm.text3.value)*5/100
EmpForm.Text5.value=Cint(EmpForm.text3.value)*2/100
End select
End sub

Sub save()
objrs.Fields(0)=Cint(EmpForm.Text1.value)
objrs.Fields(1)=EmpForm.Text2.value
objrs.Fields(2)=EmpForm.Text21.value
objrs.Fields(3)=Cint(EmpForm.Text3.value)
objrs.Fields(4)=Cint(EmpForm.Text4.value)
objrs.Fields(5)=Cint(EmpForm.Text5.value)
objrs.Fields(6)=Cint(EmpForm.Text6.value)
objrs.Fields(7)=Cint(EmpForm.Text7.value)
End sub

Sub display()
msgbox "display"
EmpForm.Text1.value=objrs.Fields(0)
EmpForm.Text2.value=objrs.Fields(1)
EmpForm.Text21.value=objrs.Fields(2)
EmpForm.Text3.value=objrs.Fields(3)
EmpForm.Text4.value=objrs.Fields(4)
EmpForm.Text5.value=objrs.Fields(5)
EmpForm.Text6.value=objrs.Fields(6)
EmpForm.Text7.value=objrs.Fields(7)
End sub

Sub search()
id=InputBox("Enter the Employee id to search")
objrs.Open"select * from emp where Eno=" & Cint(id),objconn,adOpenStatic,adLockOptimistic
msgbox"Search"
if objrs.bof or objrs.eof then
msgbox "NO RECORD"
objrs.close
exit sub
End if

display()
objrs.Close
End sub

sub cl()
EmpForm.Text1.value=" "
EmpForm.Text2.value=" "
EmpForm.Text21.value="Manager"
EmpForm.Text3.value=" "
EmpForm.Text4.value=" "
EmpForm.Text5.value=" "
EmpForm.Text6.value=" "
EmpForm.Text7.value=" "
End sub

sub newrec()
msgbox "Add"
objrs.Open"select * from emp",objconn,adOpenStatic,adLockOptimistic
objrs.AddNew()
save()
objrs.Update
MsgBox "Record is Added"
objrs.Close
End sub

sub process()
EmpForm.Text6.value=Cint(EmpForm.Text3.value)+Cint(EmpForm.Text4.value)
EmpForm.Text7.value=Cint(EmpForm.Text6.value)-Cint(EmpForm.Text5.value)
End sub

sub confirms()
Msgbox "Update"
objrs.Open"select * from emp where
Eno="&Cint(EmpForm.text1.value),objconn,adOpenStatic,adLockOptimistic
save()
objrs.Update
MsgBox"Record Updated"
objrs.Close
end sub

sub del()
objrs.Open "delete from emp where Eno="
&Cint(EmpForm.Text1.value),objconn,adOpenStatic,adLockOptimistic
cl()
MsgBox "Record Deleted"
objrs.Close
end sub

sub navi()
objrs.Open"select * from emp",objconn,adOpenStatic,adLockOptimistic
if objrs.BOF or objrs.EOF Then
MsgBox"Empty Table"
exit sub
end if
objrs.MoveFirst

Do While not objrs.EOF


display()
objrs.MoveNext
loop
objrs.Close
end sub

</script>
</head>

<body>
<form name="EmpForm">
<b> <u> <center> Employee PayRoll Preparation </center> </b> </u>
<br> <br>
Emp Id:<input type="TextBox" Name="Text1" value="0">
<br> <br>
EmpName:<input type="TextBox" name="Text2" value="Name">
Designation:<input type="TextBox" name="Text21" value="design">
<select Name="d1" onChange="designation()">
<option> Manager </option>
<option> Asst.Manager </option>
<option> Accountant </option>
</select> <br> <br>
Basic pay:<input type="TextBox" Name="Text3" value="0">
<br> <br>
Allowance:<input type="TextBox" name="Text4" value="0">
<br> <br>
Deduction:<input type="TextBox" name="Text5" value="0">
<br> <br>
Gross Pay:<input type="TextBox" name="Text6" value="0">
<br> <br>
Net Pay:<input type="TextBox" name="Text7" value="0">
<br> <br>
<input type="button" name=button1" value="clear form" onClick="cl()">
<br> <br>
<input type="button" name=button2" value="calculate pay" onClick="process()">
<br> <br>
<input type="button" name=button7" value="search" onClick="search()">
<br> <br>
<input type="button" name=button3" value="save record" onClick="newrec()">
<br> <br>
<input type="button" name=button4" value="Edit and update" onClick="confirms()">
<br> <br>
<input type="button" name=button5" value="Delete" onClick="del()">
<br> <br>
<input type="button" name=button6" value="Next" onClick="navi()">
<br> <br>
</form>
</body>
</html>
OUTPUT:

EMPLOYEE DATABASE VALIDATION


RESULT:
Thus the Paybill program in VBScript has been designed and executed successfully.
ASP
PROGRAMS
EX:NO:13 LOGIN FORMS

AIM:
To design an Asp.net application that will have a login form and make it expire after 10000
milliseconds.

ALGORITHM:

Step 1: Create a new website in Asp.net.


Step 2: In default.aspx web form, create a function named as upclk().
Step 2.1: Create a variable ‘+’ which will include a setTimeOut to display a message “your session
expired! Sorry!!!” and it will close the window using close() method.
Step 3: In the onLoad() event of the body part call upchk() function.
Step 4: Create the login screen with id as login1.
Step 5: In login1 authenticate event check whether the user value is “cttewc” and the password is
“cttewc”.
Step 5.1: Display a message “You can enter” and being the response object to open a default.aspx
web form
Step 5.2: Else display a message “Sorry! You cannot enter.”
Step 6: In defaulf.aspx design form which will display the text “Chevalier T.Thomas Elizabeth
College for Women, Chennai-11”.
Step 7: Save the file and execute in the Internet Explorer.

SOURCE CODE:

<!-----Login Form
<!-----login1.aspx
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="login1.aspx.vb" Inherits="WebApplication1._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>Untitled Page</title>
<script type="text/javascript">
function upchk()
{
var d=setTimeout("alert('your session expired!!!')+self.close()",10000);
}
</script>
</head>
<body onload="upchk()">
<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server">
</asp:Login>
</div>
</form>
</body>
</html>

<------login2.aspx
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="login2.aspx.vb" Inherits="WebApplication1.login2" %>
<!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>Untitled Page</title>
</head>
<body>
<p>
WELCOME TO THE WEBPAGE</p>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

<-----login1.aspx.vb

Partial Public Class _Default


Inherits System.Web.UI.Page
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
If Login1.UserName = "cttewc" And Login1.Password = "cttewc" Then
MsgBox("you can enter")
Response.Redirect("login2.aspx")
Else
MsgBox("sorry!!! you cannot enter")
End If
End Sub
End Class
OUTPUT:

LOGIN FORMS
RESULT:

Thus, the login page in ASP.NET application has been designed and executed
successfully.
EX:NO:14 MANIPULATION OF EMPLOYEE DATABASE

AIM:
To design an Asp.net application for creating an employee database and manipulate the records
using the commands in Asp.net

ALGORITHM:

Step 1: Create an Asp.file as ‘emp’


Step 2: In the OLEDB connection, set the provider and data source connection file
Step 3: When the add button is clicked, the function for the button 1click event is called
Step 3.1: Open the connection
Step 3.2: Stet the insert query to the command text
Step 3.3: Execute the query
Step 3.4: Show the message box as “employee details added”
Step 3.5: Clear the textbox.
Step 3.6: End of the function
Step 4: When the delete button is clicked, the function for the button 2 is called..
Step 4.1: Open the connection
Step 4.2: Set the delete query with command text
Step 4.3: Execute the query
Step 4.4: Clear the textboxes
Step 4.5: End of the function
Step 5: When the search button is clicked, the function for the button 3 is called
Step 5.1: Get the empid from the user using inputbox
Step 5.2: Set the select query in select command
Step 5.3: Show the records in the datagrid and in their corresponding fields
Step 5.4: End of the function
Step 6: When the update button is clicked the function for the button is called
Step 6.1: Open the connection
Step 6.2: Set the update query into the command text
Step 6.3: Execute the query
Step 6.4: Clear the textbox
Step 7: When the clear button is clicked, the function for the button 6 is called
Step 7.1: Clear all fields
Step 7.2: End of the function
Step 8: Save and execute in the Internet Explorer
SOURCE CODE:
Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Employee.aspx.vb" 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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Emp Name"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server" Width="102px"></asp:TextBox>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&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;&n
bsp;&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;&n
bsp;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="Add" Height="30px" Width="58px" />
<p>
<asp:Label ID="Label2" runat="server" Text="Emp id"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server" Width="104px"></asp:TextBox>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&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;&n
bsp;&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;&n
bsp;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" Text="Update" Height="26px" Width="57px" />
</p>
<asp:Label ID="Label3" runat="server" Text="Designation"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Manager</asp:ListItem>
<asp:ListItem>Asst Manager</asp:ListItem>
<asp:ListItem>Employee</asp:ListItem>
</asp:DropDownList>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&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;&n
bsp;&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;&n
bsp;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button3" runat="server" Text="Delete" Height="30px"
Width="60px" />
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="Basic Pay"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox3" runat="server" Width="105px"></asp:TextBox>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&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;&n
bsp;&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;&n
bsp;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button4" runat="server" Text="Search" />
<br />
<asp:Label ID="Label5" runat="server" Text="Allowance"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox4" runat="server" Width="106px"></asp:TextBox>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&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;&n
bsp;&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;&n
bsp;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button5" runat="server" Text="Clear" Height="30px"
style="margin-top: 26px" Width="60px" />
<br />
&nbsp;<br />
<asp:Label ID="Label6" runat="server" Text="Deduction"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox5" runat="server" Width="104px"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label7" runat="server" Text="Gross Pay"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox6" runat="server" Width="104px"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label8" runat="server" Text="Net Pay"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox7" runat="server" Width="102px"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;
&nbsp;&nbsp;
&nbsp;
&nbsp;
<asp:DataGrid ID="DataGrid1" runat="server" BackColor="White"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Horizontal">
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right"
Mode="NumericPages" />
<AlternatingItemStyle BackColor="#F7F7F7" />
<ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
</asp:DataGrid>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</form>
</body>
</html>

Default.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page
Dim cn1 As New OleDbConnection
Dim cn As New
OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;DataSource=F:\Anu\Employee\emp.mdb")
Dim cmd As New OleDbCommand
Dim dbadp As New OleDbDataAdapter
Dim dbset As New DataSet
Dim n As Integer
Dim no As Integer

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button1.Click
cmd.Connection = cn
cmd.Connection.Open()
cmd.CommandText = "Insert into table1 values(" & Val(TextBox1.Text) & "," & TextBox2.Text & ",' "
& DropDownList1.Text & " '," & Val(TextBox3.Text) & "," & Val(TextBox4.Text) & "," &
Val(TextBox7.Text) & " "
cmd.ExecuteNonQuery()
MsgBox("Employee Details Added")
Clear()
DataGrid1.databind()
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button2.Click
cmd.Connection = cn
cmd.Connection.Open()
cmd.CommandText = "update table1 set empname=' " & TextBox2.Text & " ',designation=' " &
DropDownList1.Text & " ',basic pay=" & Val(TextBox4.Text) & ",deduction=" & Val(TextBox5.Text) &
",gross pay=" & Val(TextBox6.Text) & ",net pay=" & Val(text7.text) & " where emp id= " &
Val(TextBox1.Text)
cmd.ExecuteNonQuery()
MsgBox("Employee Details updated")
Clear()
DataGrid1.DataBind()
End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button3.Click
cmd.Connection = cn
cmd.Connection.Open()
cmd.CommandText = "Delete from table1 where empid=" & Val(TextBox1.Text)
cmd.ExecuteNonQuery()
MsgBox("Deleted Succesfully")
Clear()
DataGrid1.DataBind()
End Sub

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button4.Click
Dim no As Integer
no = CInt(InputBox("Enter the no to search"))
SqlDataSource1.SelectCommand = "select * from table1 where like" & no
cmd.Connection = cn
cmd.Connection.Open()
cmd.CommandText = "select * from table1 where empid=" & no
cmd.ExecuteNonQuery()
dbadp = New OleDbDataAdapter("select * from table1 where empid=", no)
dbadp.Fill(dbset, "table1")

End Sub
End Class
OUTPUT:

EMPLOYEE DATABASE
RESULT:

Thus the application in Asp.net for manipulation of employee database has been created and
executed successfully
EX:NO:15 USAGE OF REQUEST AND RESPONSE OBJECT

AIM:
To design a Asp.net application for the usage of request and response object.

ALGORITHM:

Step 1: Create a new website in Asp.net


Step 2: Create three forms named as Default.aspx, Default2.aspx, Default3.aspx.
Step 3: In the Default.aspx webform create four buttons named as Response.write, Response.writefile,
Response.Redirect, Request.Object
Step 4: In the click event of the Response. Write button print the text as “Write is used to print the text in
webpage”
Step 5: In the click event of the Response.writefile button open the Default2.aspx using the redirect.object
Step 6: In the Default2.aspx webform , create a label and two buttons named as browser and home
Step 6.1: In the click event of browser button print the browser capabilities using the request.object in the
label
Step 6.2: In the onclick event of home button, using Redirect object comeback to the previous webpage
Step 7: In the click event of request object button using redirect open the Default3.aspx
Step 7.1: In Default3.aspx create a label and two button named as server and home
Step 7.2: In the click event of the server button using the request object print the server variable in label
Step 7.3: In the click event of home button using redirect object comeback to the previous webpage which
is Default.aspx
Step 8: save and execute in Internet Explorer

SOURCE CODE:

Default.aspx:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" 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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;
</p>
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
&nbsp;</p>
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="Browser" />
&nbsp;</p>
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" Text="Home" Width="66px" />
&nbsp;</p>
</form>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;
</p>
</body>
</html>

Default.aspx.vb

Partial Class _Default


Inherits System.Web.UI.Page

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button2.Click
Response.Redirect("Request.aspx")
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button1.Click
Dim BCaps As HttpBrowserCapabilities
BCaps = Request.Browser
Label1.Text = Label1.Text & "AOL" & BCaps.AOL & "<br>" & "Supports BG sound:" &
BCaps.BackgroundSounds & "<br>" & "BetaBrowser:" & BCaps.Beta & "BrowserName:" &
BCaps.Crawler & "<br>" & "Browser MajorVersion:" & BCaps.MajorVersion & "<br>" & "Browser
MinorVersion:" & BCaps.MinorVersion & "<br>" & "<br>" & "<br>" & "platform:" & BCaps.Platform
& "<br>" & "Is Win 16:" & BCaps.Win16 & "<br>"
End Sub
End Class

Default2.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"


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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;
</p>
<p>
&nbsp;</p>
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;
WELCOME TO REDIRECT AND OBJECT PAGE</p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="Server" Width="63px" />
</p>
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" Height="24px" Text="Home"
Width="66px" />
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;
</p>
</form>
</body>
</html>

Default2.aspx.vb

Partial Class Default2


Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button1.Click
Dim namearray() As String
Dim VisitorSv As NameValueCollection
Dim i As Integer
VisitorSv = Request.ServerVariables
namearray = VisitorSv.AllKeys
For i = 0 To UBound(namearray)
If namearray(i) <> "All_http" And namearray(i) <> "All_Raw" Then
Label1.Text = Label1.Text & namearray(i) & ":" & VisitorSv.Item(i) & "<br>"
End If

Next
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button2.Click
Response.Redirect("Request.aspx")
End Sub
End Class

Request.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Request.aspx.vb" 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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;USA
GE
OF&nbsp;
REQUEST AND RESPONSE OBJECT</p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="WRITE" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" Text="WRITEFILE" />
</p>
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;
<asp:Button ID="Button3" runat="server" Text="REDIRECT" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button4" runat="server" Text="REQUEST" />
</p>
</form>
</body>
</html>

Request.aspx.vb

Partial Class _Default


Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button1.Click
Response.Write("Write is used to print the text in web.....HAVE A GOOD DAY!!!")
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button2.Click
Response.WriteFile("G:\Anu\Request\samp.txt")
End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button3.Click
Response.Redirect("Default.aspx")
End Sub

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button4.Click
Response.Redirect("Default2.aspx")
End Sub
End Class

OUTPUT

REQUESR AND RESPONSE OBJECT OBJECT


RESULT:

Thus the Asp.net Application for the usage of request and response object has been created and
executed successfully.
EX:NO:16 GETTING THE EXACT LIST OF HEADER USING REQUEST OBJECT

AIM:

To design an asp.net application which gives the list of header using request object.

ALGORITHM:

Step 1: Create a website in Asp.net


Step 2: Create a new webform “Header.aspx”.
Step 3: In the webform create a label box with text “Header details” and id = “label”
Step 4: Then “create a button with id as “button1” and text “Click me to view files”.
Step 5: Create a procedure button click which is called when the button1 is clicked.
Step 6: Create a control variable I and initialize it to Zero inside for loop.
Step 6.1: Assign Label1.text=”<table1>” to place header items inside the table.
Step 6.2: Using getkey(i) get the inside values of header items and using request.header(i)
Step 7: Get the value of header item stored in i then concatenate them along with label1.text and
display it inside the label.
Step 8: In the onClick event calls the function “Button2-Click”.
Step 8.1: Create a procedure clr() when the button2 is clicked, clear the content inside the
label1.text=” “
Step 9: Then close the HTML table tag which is assigned to the label.
Step 10: Save the file and execute it using Internet Explorer.

OUTPUT:

HEADER OBJECT
RESULT:
Thus, the application in ASP.NET using header file has been designed and execute
successfully.
EX:NO:17 MANIPULATIONOF STUDENT DATABASE

AIM:
To design an Asp.net application for the manipulation of student database.

ALGORITHM:

Step 1: Create a new website in Asp.net


Step 2: Set a Variable cn1 as new OLEDB connection,cn as new OLEDB connection
(“provider=Microsoft.Jet.OLEDB.4.0.Datasource=D:\HTML FILES\stu1.mdb”)
Step 2.1: Declare cmd as new OLEDB command dbadp as new OLEDB DataAdapter, dbset as
new dataset, n and n as integer, name as string.
Step3: Create “Insert” button that calls ‘button1_click” function which uses cmd connection to
add the record in the database. The added record can be viewed in the Datagrid.
Step 4: Create “Delete” button that calls “button2_click” function which uses cmd connection to
delete the record from the database.
Step 5: Create “Search” button that calls “button3_click” function which is used to search a
particular record from the database that can be viewed in datagrid and the corresponding
fields.
Step 6: Create “Update” button that calls ‘button4_click” function which uses cmd connection to
update the record in the database. The updated record can be viewed in the Datagrid.
Step 7: Create “Clear” button that calls ‘button5_click” function which clear the content.
Step 8: Create “total” button that calls ‘button6_click” function to calculate total marks of the
student.
Step 9: Save the file and execute.

SOURCE CODE:

< -----Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="default.aspx.vb" 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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&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;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label1" runat="server" Text="STUDENT DATABASE"></asp:Label>
<br />
<br />
&nbsp;&nbsp;
<asp:Label ID="Label2" runat="server" Text="REG NO"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" style="height: 26px" Text="UPDATE" />
<asp:Button ID="Button2" runat="server" Text="DELETE" />
<asp:Button ID="Button3" runat="server" Text="ADD" />
<asp:Button ID="Button4" runat="server" Text="CLEAR" />
<asp:Button ID="Button5" runat="server" style="height: 26px" Text="SEARCH" />
<asp:Button ID="Button6" runat="server" Text="PROCESS" />
<br />
&nbsp;&nbsp;
<br />
&nbsp;&nbsp;
<asp:Label ID="Label3" runat="server" Text="NAME"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label4" runat="server" Text="M1"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label5" runat="server" Text=" M2"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label6" runat="server" Text="M3"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;
<br />
&nbsp;&nbsp;
<asp:Label ID="Label7" runat="server" Text="TOTAL"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
&nbsp;<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:aspstudentConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:aspstudentConnectionString2.ProviderName %>"
SelectCommand="SELECT * FROM [aspstud]"></asp:SqlDataSource>
<asp:DataGrid ID="DataGrid1" runat="server" DataSourceID="SqlDataSource1">
</asp:DataGrid>
<br />
<br />
<br />
<br />
<br />
<br />
</form>
</body>
</html>

Default.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Partial Class _default
Inherits System.Web.UI.Page
Dim cn1 As New OleDbConnection
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\kar3bca\student\aspstudent.mdb")
Dim cmd As New OleDbCommand
Dim dbset As New DataSet
Dim dbadp As New OleDbDataAdapter
Dim regno As Integer
Dim n As Integer
Dim name As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button1.Click
1: cmd.Connection = cn
cmd.Connection.Open()
cmd.CommandText = "update aspstud set name=' " & TextBox2.Text & " ' , m1=" &
Val(TextBox3.Text) & " , m2=" & Val(TextBox4.Text) & " ,m3=" & Val(TextBox5.Text) & " , total=" &
Val(TextBox6.Text) & " where regno=" & Val(TextBox1.Text)
cmd.ExecuteNonQuery()
MsgBox("student details updated")
clear()
DataGrid1.DataBind()
End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button3.Click
cmd.Connection = cn
cmd.Connection.Open()
cmd.CommandText = "insert into aspstud values(" & Val(TextBox1.Text) & ",'" & TextBox2.Text
& "'," & Val(TextBox3.Text) & "," & Val(TextBox4.Text) & "," & Val(TextBox5.Text) & "," &
Val(TextBox6.Text) & ")"
cmd.ExecuteNonQuery()
MsgBox("student details added")
clear()
DataGrid1.DataBind()
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button2.Click
cmd.Connection = cn
cmd.Connection.Open()
cmd.CommandText = "delete from aspstud where regno=" & Val(TextBox1.Text)
cmd.ExecuteNonQuery()
MsgBox("deleted successfully")
clear()
DataGrid1.DataBind()
End Sub

Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button5.Click
Dim regno As Integer
regno = Val(InputBox("enter the no to be searched:"))
SqlDataSource1.SelectCommand = "select*from aspstud where regno=" & regno
cmd.Connection = cn
cmd.Connection.Open()
cmd.CommandText = "select* from aspstud where regno=" & regno
cmd.ExecuteNonQuery()
DataGrid1.DataBind()
End Sub

Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button6.Click
TextBox6.Text = Val(TextBox3.Text) + Val(TextBox4.Text) + Val(TextBox5.Text)
End Sub

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button4.Click
clear()
End Sub

Public Sub clear()


TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
TextBox5.Text = " "
TextBox6.Text = " "
End Sub
End Class
OUTPUT:

STUDENT DATABASE
RESULT:
Thus, the Student database is manipulated using ASP.NET application and it has been
designed and executed successfully.
EX:NO:18 ONLINE BOOKSHOP

AIM:

To design Asp.net application that describes book in the online bookshop.

ALGORITHM:

Step 1: Create a new website in Asp.net.


Step 2: Create form name as “Default.aspx”, “Default2.aspx” , “Default3.aspx” ,“Default4.aspx”.
Step 3: In Default.aspx web form, create an Adrotator to rotate different images in each coding
by using XML file.
Step 3.1: In Default2.aspx web form, create the text “CTTE Book house, Sembium, Chennai – 11”
by using <span> tag.
Step 3.2: In Default3.aspx web form, create and add the text at the top by using <span> tag.
Step 4: In the “BulletList1” display the General books at the list item.
Step 5: In the “BulletList2” display the Science books at the list item.
Step 6: In the “BulletList3” display the English books at the list item.
Step 7: In Default4.aspx web form, create the book offer details by using <span> tag.
Step 8: Save and execute the file “Default.aspx” then picture will be displayed randomly.

SOURCE CODE:

Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" 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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<p style="font-size: large; font-weight: 700; text-align: center">
ONLINE BOOK SHOP</p>
<p style="text-align: center">
<asp:AdRotator ID="AdRotator1" runat="server"
AdvertisementFile="~/XMLFile.xml" />
</p>
</form>
</body>
</html>

Default2.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"


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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center; font-size: large; font-weight: 700">

CTTE BOOK HOUSE<br />


SEMBIUM<br />
CHENNAI-11<br />
(ONLINE BOOK SHOP)</div>
</form>
</body>
</html>

Default3.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb"


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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center; font-size: large; font-weight: 700">

BUY BOOKS FOR RS 1000/- AND ABOVE<br />


GET A DISCOUNT FOR 10%<br />
BUY CHILDREN&#39;S BOOKS AND GET DISCOUNT 20%<br />
SPECIAL OFFER FOR STUDENTS ARE ALSO GIVEN</div>
</form>
</body>
</html>

Default4.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default4.aspx.vb"


Inherits="Default4" %>

<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
WELCOME TO CTTE</form>
</body>
</html>

XML FILE:

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


<Advertisements Xmlns ="https://schemas.microsoft.com/Aspnet/Adrotatorschedule_file">
<Ad Xmlns=" ">
<ImageUrl>book1.png</ImageUrl>
<NavigateUrl>default2.aspx</NavigateUrl>
<AlternateText>ADVERTISEMENT</AlternateText>
<Impressions>100</Impressions>
<Keyword>Header</Keyword>
</Ad>
<Ad Xmlns=" ">
<ImageUrl>book2.jpg</ImageUrl>
<NavigateUrl>default3.aspx</NavigateUrl>
<AlternateText>ADVERTISEMENT</AlternateText>
<Impressions>50</Impressions>
<Keyword>Header</Keyword>
</Ad>
<Ad Xmlns=" ">
<ImageUrl>book3.jpg</ImageUrl>
<NavigateUrl>default4.aspx</NavigateUrl>
<AlternateText>ADVERTISEMENT</AlternateText>
<Impressions>50</Impressions>
<Keyword>Header</Keyword>
</Ad>
</Advertisements>

OUTPUT:

ONLINE BOOKSHOP
RESULT:

Thus, the ASP.NET application that describes books in Online Book Shop has been
designed and executed successfully.
EX:NO:19 USING ONMOUSEOVER FOR HYPERLINK

AIM:

To design an Asp.net application that will navigate the new page when the mouse is over
in Hyperlink.

ALGORITHM:

Step 1: Create a website in Asp.net.


Step 2: Create a form “Hyperlink.aspx”
Step 3: In the form create a hyperlink with text “CTTE college for women” and id as hyperlink1.
Step 3.1: In the onmouseover event call hyperlink1 attributes add, which contain the onmouseover
and click() event.
Step 4: Create another form “default2.aspx”.
Step 4.1: Design the form which contain list of courses offered using bullets list .
Step 4.2: Link “Default2.aspx” with hyperlink using navigate URL.
Step 5: Save the file and execute it using Internet Explorer.

SOURCE CODE:

Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" 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>Untitled Page</title>
</head>
<body>
<p>
<br />
</p>
<p>
&nbsp;</p>
<p style="height: 28px; width: 434px; margin-left: 400px">
USING MOUSEOVER FOR A HYPERLINK</p>
<p style="height: 40px; width: 615px; font-family: 'Times New Roman', Times, serif; font-size: xx-
large; margin-left: 320px">
C.T.T.E COLLEGE FOR WOMEN</p>
<p style="height: 24px; width: 488px; font-family: 'Times New Roman', Times, serif; font-size:
medium; margin-left: 380px">
Move the mouse over the Hyperlink to view the details</p>
<form id="form1" runat="server">
<div style="height: 21px; width: 321px; margin-left: 444px;">

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="default2.aspx">DEPARTMENTS


AVAILABLE</asp:HyperLink>

</div>
<p style="height: 25px; width: 355px; margin-left: 422px">
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="default3.aspx">EXTRA
CURRICULAR ACTIVITIES</asp:HyperLink>
</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
</form>
</body>
</html>

Default.aspx.vb

Partial Class _Default


Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


HyperLink1.Attributes.Add("onmouseover", "click()")
HyperLink2.Attributes.Add("onmouseover", "click()")
End Sub
End Class

Default2.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"


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>Untitled Page</title>
<style type="text/css">
.style1
{
font-size: large;
font-weight: bold;
}
</style>
</head>
<body>
<p>
<br />
</p>
<p>
&nbsp;</p>
<p class="style1">
CTTE COLLEGE FOR WOMEN</p>
<p>
DEPARTMENTS AVAILABLE:</p>
<form id="form1" runat="server">
<div>

<asp:BulletedList ID="BulletedList1" runat="server">


<asp:ListItem>BCA</asp:ListItem>
<asp:ListItem>B.SC</asp:ListItem>
<asp:ListItem>BA</asp:ListItem>
<asp:ListItem>B.COM</asp:ListItem>
</asp:BulletedList>

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

Default3.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb"


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>Untitled Page</title>
<style type="text/css">
.style1
{
font-size: large;
font-weight: bold;
}
</style>
</head>
<body>
<p>
<br />
</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p class="style1">
CTTE COLLEGE FOR WOMEN</p>
<p class="style1">
EXTRA CURRICULAR ACTIVITIES:</p>
<form id="form1" runat="server">
<div>

<asp:BulletedList ID="BulletedList1" runat="server">


<asp:ListItem>DRAWING</asp:ListItem>
<asp:ListItem>SINGING</asp:ListItem>
<asp:ListItem>DANCING</asp:ListItem>
<asp:ListItem>SPORTS</asp:ListItem>
<asp:ListItem>NSS</asp:ListItem>
<asp:ListItem>ED CELL</asp:ListItem>
<asp:ListItem>CULTURALS</asp:ListItem>
</asp:BulletedList>

</div>
</form>
</body>
</html>
OUTPUT:

USING ONMOUSEOVER FOR A HYPERLINK


RESULT:

Thus, an ASP.NET application using mouseover event for Hyperlink has been designed
and executed successfully.
EX:NO:20 LOADING AND UNLOADING A USER DEFINED PAGE

AIM:

To design an asp.net application for using loading and unloading a user defined page.

ALGORITHM:

Step 1: Create a new website in Asp.net.


Step 2: In this form create two HTML buttons named as “OPEN” and “CLOSE”
Step 3: In the Click event of open button, it calls the click() function which BY default opens the
Defaut2.aspx
Step 4: In the Default2.aspx webform design a web page.
Step 5: In open window function display a message “HAI”.
Step 6: In the click event of close button, close the window using close() method.
Step 7: In the Close() method,create a variable ‘t’ which wll have setTimeOut to close the
window using Selfclose() method.
Step 8: In onLoad event of the body call the function close window.
Step 9: In the form design the page with text CTTE college for Women.
Step 10: Save the file and execute it using Internet Explorer.

SOURCE CODE

Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" 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>Untitled Page</title>
<script type="text/javascript">
function click1()
{
alert("HAI")
var d=open("default2.aspx","_blank","menubar=no,resizeable=yes,toolbar=no,status=no,address=no")
}
function click2()
{
self.close()
}
</script>
<style type="text/css">
.style1
{
text-align: center;
}
#Button2
{
margin-left: 421px;
}
#Button1
{
margin-left: 424px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">

<h2 class="style1">
<b>LOADING AND UNLOADING A USER DEFINED PAGE
</b>
</h2>
<br />
CLICK THE <b>OPEN</b> BUTTON&nbsp; TO LOAD THE USER DEFINED&nbsp; PAGE
AND
CLICK THE <b>CLOSE</b> BUTTON TO UNLOAD THE WEBPAGE</div>
<p>
&nbsp;</p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;
<input id="Button1" type="button" value="OPEN" onclick="click1()"/></p>
<p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp; </p>
<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input id="Button2" type="button" value="CLOSE" onclick="click2()"/></form>
<p>
&nbsp;</p>
</body>
</html>

Default2.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"


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>Untitled Page</title>
<style type="text/css">
.style1
{
font-family: "Times New Roman", Times, serif;
}
.style3
{
text-align: center;
font-family: "Times New Roman", Times, serif;
}
.style4
{
background-color: #00CC00;
}
.style5
{
font-family: "Times New Roman", Times, serif;
text-align: center;
background-color: #FF9933;
}
.style6
{
background-color: #FF9933;
}
.style7
{
width: 507px;
text-align: right;
margin-left: 193px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-left: 160px">

<h1 class="style3">
&nbsp;</h1>
<h1 class="style3">
<span class="style4">CTTE COLLEGE FOR WOMEN</span></h1>
<p class="style3">
&nbsp;</p>
<h2 class="style7">
<br class="style1" />
<span class="style5">NO:16,ST MARYS ROAD,SEMBIUM,</span><span class="style6"><br
class="style1" />
</span>
</h2>
<h2 class="style7">
<span class="style5">CHENNAI-600 068</span></h2>
<h2 class="style7">
<span class="style6"><br class="style1" />
</span><span class="style5">PHONE-2537 5753.</span></h2>
</div>
</form>
</body>
</html>
OUTPUT:

LOADING AND UNLOADING A USER DEFINED PAGE


RESULT:

Thus, an ASP.NET application for loading and unloading a user defined page has been designed
and executed successfully.
EX:NO:21 COOKIES

AIM:

To design on Asp.net application that will implement a hit counter using cookies.

ALGORITHM:

Step 1: Create a new website in Asp.net


Step 2: Declare variables a,i,n,c as integer.
Step 3: When the manipulate cookies button is clicked the following task will be takes place.
Step 3.1: Store the number of cookies in variable ‘n’.
Step 3.2: Check if n=0, find if yes, assign i=1.
Step 3.3: Else in the control for loop print how many times the user visited the page and also the
user name.
Step 3.4: Check if c=0, if true, print the statement “You are visiting the page for first time” in the
message box.
Step 3.5: End of sub procedure.
Step 4: When the login button is clicked, the following task will take place.
Step 4.1: Using the loop cookies names are printed over label2.
Step 5: When the delete cookie button is clicked, the following task will take place.
Step 5.1: Get the index value from user and store it in ‘t’ variable .
Step 5.2: Print the username in the msgbox.
Step 6: Save the file and execute it using Internet Explorer.

SOURCE CODE:

Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"


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>Untitled Page</title>
<style type="text/css">
.style1
{
font-family: "Times New Roman", Times, serif;
font-size: xx-large;
}
.style2
{
text-decoration: underline;
font-weight: bold;
}
.style3
{
font-size: large;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

&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;&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;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;<span class="style1"> <span
class="style2">COOKIES</span></span></div>
<p>
&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;&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; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
class="style3">
<asp:Label ID="Label1" runat="server" Text="Enter your name"></asp:Label>
&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;
<asp:TextBox ID="TextBox1" runat="server" Width="170px"></asp:TextBox>
</p>
<p>
&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;&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" Height="40px" Text="Manipulate cookie"
Width="151px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" Height="40px" Text="Login"
Width="116px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
<asp:Button ID="Button3" runat="server" Height="36px" Text="Delete"
style="margin-left: 0px" Width="138px" />
</p>
&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;&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;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>

Default.aspx.vb

Partial Class _Default


Inherits System.Web.UI.Page
Dim a As Integer
Dim n As Integer
Dim c As Integer = 0
Dim i As Integer

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button1.Click
Label2.Text = ""
' Dim ct As Integer
n = Request.Cookies.Count
MsgBox("Total no of cookies created:" & n)
Dim x, y
For Each x In Request.Cookies
If x IsNot Nothing Then
Label2.Text = Label2.Text & " " & Request.Cookies(x).Name & vbCrLf &
Request.Cookies(x).Value & vbCrLf
Else
Response.Write(x & "=" & Request.Cookies(x) & "<br>")
End If
Next

'For ct = 0 To n - 1
' For Each y In Request.Cookies(x)
' 'MsgBox(Request.Cookies.Item(ct).Value)
' 'If Request.Cookies.Item(ct).Value <> Nothing Then

' Label2.Text = Label2.Text & " " & Request.Cookies.Item(ct).Name & vbCrLf &
Request.Cookies.Item(ct).Value & vbCrLf & Request.Cookies("user[" & ct & "]")("uname")
' 'End If

' Next
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button2.Click
n = Request.Cookies.Count
If n = 0 Then
i=0
Else
For i = 0 To n - 1
If Not (Request.Cookies("user[" & i & "]") Is Nothing) Then
If Request.Cookies("user[" & i & "]")("uname") = TextBox1.Text Then
Response.Cookies("user[" & i & "]")("uname") = TextBox1.Text
a = Val(Request.Cookies("user[" & i & "]")("count")) + 1
Response.Cookies("user[" & i & "]")("count") = a.ToString()
Response.Cookies("user[" & i & "]").Expires = DateTime.Now.AddDays(1)
MsgBox(Request.Cookies("user[" & i & "]")("uname") & "is visiting the page "
& a & " times")
c=1
Else
c=0
End If
Else
Exit For
End If
Next
End If
If c = 0 Then
MsgBox("i=" & i)
Response.Cookies("user[" & i & "]")("uname") = TextBox1.Text
Response.Cookies("user[" & i & "]")("count") = "1"
Response.Cookies("user[" & i & "]").Expires = DateTime.Now.AddDays(1)
MsgBox("you are visiting the page first time")

End If
End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button3.Click
Dim del As Integer
del = Val(InputBox("Enter the index of the cookie to be deleted"))
MsgBox(Request.Cookies("user[" & del & "]")("uname"))
Response.Cookies("user[" & del & "]").Expires = DateTime.Now.AddDays(-2)
MsgBox("cookie deleted")
End Sub
End Class
OUTPUT:

COOKIES
CONCLUSION:

Thus, the Cookie in Hit Counter using ASP.NET application has been executed successfully.

You might also like