Uploaded by N. Rehna madam

Web Applications manual (1)

advertisement
WEB APPLICATIONS LAB MANUAL
DEPARTMENT: Computer Science / Computer Application
CLASS
YEAR
SUB CODE
: B. Sc / BCA
: III B. Sc / III BCA
: SAE61 / SAZ61
SEMESTER: VI
SHRI SHANKARLAL SUNDARBAI SHASUN JAIN COLLEGE FOR WOMEN
VB SCRIPT & JAVASCRIPT
1. Write a program outputs the squares, roots, cubes and complements of integers
between 1 and 100.
2. Create a calculator.
3. Write a script to Sort numbers and strings
4. Create a program to generate a hit counter
5. Create a program to verify whether email address provided by user is valid or
invalid.
6. Write a program to scroll the text on status bar.
7. The form consists of two multiple choice list and one single choice list
a. the first multiple choice list display the major dishes available.
b. the second Multiple choice list display the stocks available.
c. The single choice list display the miscellaneous
(Milkshakes, soft drinks, softy available etc.)
8. Write a sript to create a digital clock.
9. Create a web page using two image file which switch black and white one another
as the mouse pointer moves over the image. Use the On Mouse over and On Mouse
event, onDblclick handler
10. Build a WWW page with an image and 3 buttons., Pick three favorite graphics,
label the buttons and make each one swap in the graphic you have chosen
11. Create a frameset that has two frames, side by side.
Make the left-hand frame contain a form with 3 radio buttons
The buttons should be for three search engines:
 Yahoo (http://www.yahoo.com)
 Altavista (http://www.altavista.com)
 Infoseek (http://www.infoseek.com)
When the user clicks on of the option buttons, the frame on the right hand side
should be loaded with the right search engine.
12.Write a program to implement Employee database with all validation
SHRI SHANKARLAL SUNDARBAI SHASUN JAIN COLLEGE FOR WOMEN
ASP
1. Create a login form, to expire, if the user does not type the password within 100 seconds
2. Create an employee database and manipulate the records using command object in ASP
3. Develop an application to illustrate the usage of Request and Response Objects in ASP.
4. Write an ASP program using Request Object to give the exact list of headers sent by the
browser to the Web server.
5. Create an Active Server Page to display the records one by one from a student database.
The student database should contain roll no, name, marks & total.
6. Design an ASP application that describes books in the Online Bookshop.(Use AD
Rotator Component, Content Rotator Component, Content Linking Component)
7. Create a document and add a link to it. When the user moves the mouse over the link it
should load the linked document on its own (User is not required to click on the link).
8. Create a document, which opens a new window without a toolbar, address bar, or a
status bar that unloads itself after one minute.
9. Create a document that accepts the user’s name in a text field form and displays the
same the next time when the user visits the site informing him that he has accessed the site
for the second time, and so on.
SQUAREROOT, CUBE AND COMPLEMENT OF AN INTEGER
AIM:
To create a program to find the square root ,cube and complement of integers
between 1 and 100.
PROCEDURE:
 Create a new file and put a normal html document structure tags in a file.
 In head section specify the title for the webpage.
 specify the script type as javascript.
 create a prompt input box that gets the two values to display the output save
the file and run it in the internet explorer.
PROGRAM:
<html>
<head>
<title>
Squareroot, cube and complement of a Number in Javascript</title>
</head>
<body bgcolor=ivory>
<h1>
<b>
Finding Squareroot, Cube and Complement of a Number
</b>
</h1>
<script language="javascript">
var sqroot;
var cube;
var comple;
var i;
var n;
n=parseInt(prompt("Enter The Number","5"));
sqroot=Math.sqrt(n);
cube=Math.pow(n,3);
comple=-n;
document.write("Number"+"="+n+"<br>");
document.write("SquareRoot of a Number"+"="+sqroot+"<br>");
document.write("Cube of a Number"+"="+cube+"<br>");
document.write("Complement of a Number"+"="+comple+"<br>");
</script>
</body>
</html>
OUTPUT:
SQUAREROOT, CUBE AND COMPLEMENT OF AN
INTEGER(VBSCRIPT)
<html>
<head>
<title>
Squareroot, cube and complement of a Number in Vbscript</title>
</head>
<body bgcolor=ivory>
<h1>
<b>
Finding Squareroot, Cube and Complement of a Number
</b>
</h1>
<script language="vbscript">
dim sqroot
dim cube
dim comple
dim n
n=InputBox("Enter The Number")
sqroot=sqr(n)
cube=n^3
comple=-n
document.write("<br>"&"Number"&"="&n&"<br>")
document.write("SquareRoot of a Number"&"="&sqroot&"<br>")
document.write("Cube of a Number"&"="&cube&"<br>")
document.write("Complement of a Number"&"="&comple&"<br>")
document.write("<br>"&"-----------------------------------"&"<p>")
</script>
</body>
</html>
OUTPUT:
RESULT:
Thus the script has been created to find the square root, cube, complement of integer
between 1 and 100.
CALCULATOR
Aim:
To create a calculator and to perform arithmetic operation using javascript.
Procedure:

create a new file and put the html document structured tags in the file .
 In the head section ,
(a)Mention the script language
(b)declare the variables
(c)Defining the functions
OPR_CLICK()
Assigning the first value to a variable n.Assigning operator to variable then it
automatically resets the value for another input.
EQUALTO()
1.Assigning the second value to the variables.
2.Then perform specific task for a particular operator.
3.In body section,
* type the contents for displaying buttons in form.
* save the file and run it in the internet explorer
Program:
<html>
<head>
<title>
CALCULATOR
</title>
<script language="JavaScript">
var first,second,ch;
function concat(x)
{
var y=document.cal.t1.value;
y=y+x;
document.cal.t1.value=y;
}
function operatorclick(n)
{
first=document.cal.t1.value;
ch=n;
document.cal.t1.value=" ";
}
function equalsto()
{
second=document.cal.t1.value;
if(ch=="+")
document.cal.t1.value=parseInt(first)+parseInt(second);
if(ch=="-")
document.cal.t1.value=parseInt(first)-parseInt(second);
if(ch=="*")
document.cal.t1.value=parseInt(first)*parseInt(second);
if(ch=="/")
document.cal.t1.value=parseInt(first)/parseInt(second);
}
</script>
</head>
<body bgcolor=ivory>
<center>
<h1>
<b>
CALCULATOR
</b>
</h1>
<form name="cal">
<input type="text" name="t1">
<br>
<input type="button" value="7" onClick=concat(7)>
<input type="button" value="8" onClick=concat(8)>
<input type="button" value="9" onClick=concat(9)>
<input type="button" value="/" onClick=operatorclick("/")>
<br>
<input type="button" value="4" onClick=concat(4)>
<input type="button" value="5" onClick=concat(5)>
<input type="button" value="6" onClick=concat(6)>
<input type="button" value="*" onClick=operatorclick("*")>
<br>
<input type="button" value="1" onClick=concat(1)>
<input type="button" value="2" onClick=concat(2)>
<input type="button" value="3" onClick=concat(3)>
<input type="button" value="-" onClick=operatorclick("-")>
<br>
<input type="button" value="0" onClick=concat(0)>
<input type="button" value="+" onClick=operatorclick("+")>
<input type="button" value="=" onClick=equalsto()>
<input type="reset" value="c">
</center>
</form>
</body>
</html>
OUTPUT:
Result:
Thus the simple calculator has been created.
SORTING THE NUMBERS AND STRINGS
Aim:
To create a javascript program that sorts the given numbers and string.
Procedure:
 To create a new file and put the normal html document structure tags in the
file.
 Using function tag add language as javascript.
 Write function for sortit and sortvalues.
 In the function sort value use the inbuilt function sort the values specified in
sortit function.
 Create 2 buttons-one for sorting alphabetically and another for sorting
numbers.
 Create a text area to display the sorted values.
 If the user enters string click sort alphabetically as well as for the sort
numbers.
Program:
<html>
<head>
<title>
SORTING
</title>
</head>
<script type="text/javascript">
function sortit(a,b)
{
return(a-b)
}
function sortvalues(param)
{
var inputvalues=document.sorter.sorter2.value.split(" ");
if(param==0)
inputvalues.sort()
else
inputvalues.sort(sortit)
document.sorter.sorter2.value='';
for(i=0;i<inputvalues.length-1;i++)
document.sorter.sorter2.value=document.sorter.sorter2.value+
inputvalues[i]+" ";
document.sorter.sorter2.value+=inputvalues[inputvalues.length-1];
}
</script>
<body bgcolor=ivory>
<center>
<h1>
<b>
SORTING THE NUMBERS AND STRINGS
</b>
</h1>
<form name="sorter">
<p>
<textarea rows="10" name="sorter2" cols="50"wrap="virtual">
</textarea>
<br>
<input type="button" value="SORT ALPHABETICALLY"
onClick="sortvalues(0)">
<input type="button" value="SORT NUMERICALLY" onClick="sortvalues(1)">
<input type="reset" value="RESET">
</form>
</center>
</body>
</html>
OUTPUT:
SORT ALPHABETICALLY:
SORT NUMERICALLY:
Result:
Thus a javascript program has been created which sorts the numbers and the
given string.
HIT COUNTER
Aim:
To create a script program to display the hit counter.
Procedure:
 STEP1:To create a new file and put the normal html document structure
tags in the file.
 Using script tag and add language as vbscript
 write the function for hit counter
 create a button for hit me in the vbscript and not for javascript.
 use the above procedure to display the hit counter.
Program:
<html>
<head>
<title>
HIT COUNTER
</title>
<script language="javascript">
var a=0,b=0,n=0;
c=new Array(10);
function gh()
{
var d=0;
if(i.j.value=="")
{
alert("USERNAME REQUIRED");
}
else
{
c[a]=i.j.value;
n++;
for(b=0;b<=n;b++)
{
if(c[b]==i.j.value)
d++;
}
alert("USERNAME"+i.j.value+"\n"+"VISITING"+d+"TIME")
a++;
}
}
</script>
</head>
<body bgcolor=ivory>
<center>
<h1>
<b>
An Example For Counting Number Of Visits To a Site
</b>
</h1>
<hr color=blue>
<form name=i>
<input type=text name=j>
<input type=button name="b2" value="Load" onClick='gh()'>
</form>
</center>
<hr color=blue>
</body>
</html>
OUTPUT:
HIT COUNTER(Vb Script)
<html>
<head>
<title>
HIT COUNTER
</title>
</head>
<script language="vbscript">
dim counter
counter=0
sub count()
counter=counter+1
MsgBox("COUNTER:"&counter)
end sub
</script>
<body bgcolor=ivory>
<center>
<h1>
<b>
HIT COUNTER
</b>
</h1>
<form name="form1 method="post" action=" ">
<input type="button" name="Button" value="HIT ME" onClick="count()">
</form>
</center>
</body>
</html>
OUTPUT:
Result:
Thus the program hit counter has been created.
E-MAIL VALIDATION
Aim:
To create a email address provided by user is valid or invalid using javascript.
Procedure:
 To create a new file and put the normal html document structure tags in
the file.
 In the head section,
(a)Mention the script language
(b)Declare the variables
(c)Defining the functions
CHECK MAIL()
*Assign the user name to the variable string
*Assign special character to the variable filter
*Check whether the client contents of the e mail ID is valid or not
*In the body section,
a)Type the contents for displaying whether the e mail ID is valid or invalid in a
form
 Save the file and run it on Internet explorer
Program:
<html>
<head>
<title>
User Validity
</title>
</head>
<body bgcolor=ivory>
<center>
<h1>
<b>
User Validity
</b>
</h1>
<script language="javascript">
var wrd=new String();
wrd=prompt("Enter Your String");
document.write("The String="+wrd+"<br>");
var a=new String();
a=prompt("Enter Your String");
document.write("The String="+a+"<br>");
if(wrd==a)
{
document.write("User is Valid");
}
else
{
document.write("User is Invalid");
}
</script>
</center>
</body>
</html>
OUTPUT:
Result:
Thus the script to verify whether the e mail ID is valid or invalid has been
created.
STATUS BAR
Aim:
To create a script to scroll the text on the status bar.
Procedure:
 Create the new file and put the normal html document structure tags in the file.
 In the head section specify the title for the web pages.
 Write the function that scrolls the text on the status bar.
 Create a button to select the text that is to be scrolled on the status bar.
 Save the file and it in internet explorer.
Program:
<html>
<head>
<title>
Status Bar
</title>
</head>
<script language="JavaScript">
var ar="It is a javascript program,to scroll the text on the status bar";
var space="";
var i;
i=1;
function count()
{
var cont,k=0;
cont="";
while(k<=i)
{
cont=cont + " ";
k++;
}
status=cont +ar;
i++;
if(i>100)
i=0;
window.setTimeout("count()",5);
}
</script>
<body bgcolor=ivory onLoad="count()">
<h1 align=center>
<b>
Status Bar Program
</b>
</h1>
</body>
</html>
OUTPUT:
Result:
Thus the script has been created to scroll the text on the status bar.
MULTIPLE CHOICE LIST
Aim:
To create a form that consists of two multiple choice list and one single choice
list.
(a)the first multiple choice list displays the major dishes available.
(b) the second multiple choice list displays the stocks available.
(c)the single list displays the miscellaneous(milk shakes, soft drinks,……….)
Procedure:
1.create new file and put the normal html document structure tags in the file.
2.In the head section specify a title for a webpage.
3.Create a function that displays the selected items and to find the total cost of the
selected items using javascript.
4.create three list box that contain stock,list,available item and miscellaneous.
5.create a frame in which the selected items will be displayed.
6.save the file and run it in the internet explorer.
Program:
<html>
<head>
<title>
McDonalds
</title>
<script language="javascript">
var m;
function pick(f1)
{
var z=" ";
for(j=0;j<3;j++)
{
for(i=0;i<f1.elements[j].length;i++)
{
if(f1.elements[j][i].selected)
{
var y=f1.elements[j].options[i].value;
z=z+"\n"+y;
f1.elements[3].value=z;
}
}
}
m=z;
}
function cal(f1)
{
var d=0;
for(j=0;j<3;j++)
{
for(i=0;i<f1.elements[j].length;i++)
{
if(f1.elements[j][i].selected)
{
var y=f1.elements[j].options[i].value;
s=new String(y);
var a=s.indexOf(">");
var b=s.substring(a+1,a+3);
c=parseInt(b);
d=d+c;
}
}
}
p="Total cost of the selected items="+d;
m=m+"\n"+p;
f1.elements[3].value=m;
}
function clr(f1)
{
f1.elements[3].value=" ";
}
</script>
</head>
<body>
<h2>
<center>
<SPAN Style="color:blue;">Welcome to the world famous fast food
center
</span>
<SPAN Style="color:red;">
McDonalds!
</span>
</center>
</h2>
<form name="f1">Select the menu of your choice<br/><br/>
<table><tr valign="top"><td> Major dishes:<br/>
<select name="s1" multiple onBlur="pick(this.form)">
<option value="mc Burger->80" selected >mc Burger</option>
<option value="Fish Fillets->70">Fish Fillets</option>
<option value="Chicken Burger->60">Chicken Burger</option>
<option value="veg burger->45">Veg burger</option>
</select><br/><br/>
</td><td></td><td></td><td>
Starters:<br/>
<select name="s2" multiple onBlur="pick(this.form)">
<option value="french fries->40">French fries</option>
<option value="nuggets->50">Nuggets</option>
<option value="hash browbns->55">hash browns</option>
<option value="mc aloo tikki->65">mc aloo tikki</option>
</select><br/><br/>
</td><td></td><td></td><td>
Miscellaneous:<br/>
<select name="s3" onBlur="pick(this.form)">
<option value=" ">'check these out'
<option value="milkshakes->35">milkshakes</option>
<option value="softdrinks->20">softdrinks</option>
<option value="softy->25">softy</option>
</select>
<br/><br/>
</td><td></td><td></td></tr></table><br/>
<table><tr valign="top"><td>
The items selected from the menu are:
<textarea name="ta1" rows="10" cols="50"></textarea><br/></br>
</td><td></td><td></td><td>
<br/><input type="button" value="Total cost" onClick="cal(this.form)"/>
<input type="button" value="Clear" onClick="clr(this.form)"/>
</td></tr></table>
</form>
</body>
</html>
OUTPUT:
Result:
Thus the program has been created with a form that consists of two multiple choice
list and a single choice list.
DIGITAL CLOCK
Aim:
To generate a digital clock using javascript.
Procedure:
 Create a new file and put the normal html document structured tags in the file.
 In the head section,
(a)Mention the script language
(b)Declare the variables
(c)Define the functions
START_TIME()
1.declare the variables for displaying date,hours,minutes,seconds.
2.Function call checktime()
Check time():
1.It checks for current time.
2.In the body section,
(a) type the contents for displaying date,hours,minutes and seconds
3.save the file and run it in the internet explorer.
Program:
<html>
<head>
<title>
DIGITAL CLOCK
</title>
</head>
<script language="JavaScript">
function getTimes()
{
var dt=new Date();
form1.t.value= dt.getHours() + ":" + dt.getMinutes() + ":" +dt.getSeconds();
window.setTimeout("getTimes()",1000);
}
</script>
<body bgcolor=ivory onLoad="getTimes()">
<center>
<h1>
<b>
DIGITAL CLOCK
</b>
</h1>
<form name="form1" method="post" action="">
<input name="t" type="text" id="t">
</form>
</center>
</body>
</html>
OUTPUT:
DIGITAL CLOCK(vbscript)
<html>
<head><title>
DIGITAL CLOCK
</title>
<script type="text/vbscript">
sub initdigitimer()
window.SetInterval "movetime", 1000
End sub
function movetime()
document.all("displaytime").innerText=time()
end function
sub window_onload()
initdigitimer()
end sub
</script>
</head>
<body bgcolor=ivory><center>
<div id=displaytime
style="position:absolute;
width:120;
height:20;
border:solid;
bordercolor:lightblue;
border-leftwidth:thin;
border-rightwidth:thin;
background-color:darkblue;
color:yellow;
font-align:center;
font-family:arial;
font-weight:bold">
</div>
</center>
</body>
</html>
OUTPUT:
Result:
Thus the script has been created to display the digital clock.
MOUSE EVENTS
Aim:
Write a script to create a webpage using two image files switch between one
another as the mouse pointer move over the image use the on mouse over and on
mouse event on double click handler.
Procedure:
1.create a new file and put the normal html document structured tags in the file.
2.In the head section,
(a) select the specific title for the webpage
(b)write the function in the javascript that loads automatically loads in the linked
document in new window.
(c)create a link to a document which when clicked cause a function.
(d)save the file and run it on the internet explorer
<html>
<head>
<title>
Mouse Events
</title>
</head>
<script language="javascript">
function img()
{
var a=window.open('lotus.jpg');
}
function img2()
{
var b=window.open('rose.jpg');
}
</script>
<body bgcolor=ivory>
<h1 align=center><b>Mouse Events</b></h1>
<img src="flowers.jpg" align="left" height=150 width=150 onDblClick='img()'>
<img src="lily.jpg" align="right" height=150 width=150 onMouseover='img2()'>
</body>
</html>
OUTPUT:
DOUBLECLICK EVENT:
MOUSE OVER EVENT:
Result:
Thus the webpage has been created when with image files which switch image
when the mouse pointer moves over the image.
SWAPPING OF THREE IMAGES
Aim:
To create a program to find the graphics images.
Procedure:
1.create a new file and put the normal html document structure tags in the file.
2.in the head section,
(a)select the title for the webpage
3.write the function in the javascript that loads automatically in the linked
document in the new windows folder.
4.rename the picture’s name in the folder
5.save the file and run it in internet explorer.
Program:
<html>
<head>
<title>
SWAPPING
</title>
<script language="javascript">
function img()
{
document.images[0].src="lotus.jpg"
}
function img2()
{
document.images[0].src="rose.jpg"
}
function img3()
{
document.images[0].src="lily.jpg"
}
</script>
</head>
<body bgcolor=ivory>
<center>
<IMG SRC="flowers.jpg" WIDTH="300">
<form name="imageForm">
<input type=button NAME="imagename" VALUE="Rose" onClick="img()">
<input type=button NAME="imagename" VALUE="Lily" onClick="img2()">
<input type=button NAME="imagename" VALUE="Lotus" onClick="img3()">
</form>
</center>
</body>
</html>
OUTPUT:
Result:
Thus the webpage has been created, in which image files has been displayed.
FRAMES
Aim:
To create a frameset that has been frames side by side.
Procedure:
*Create a new file and put the normal html document
Structure tags in the file.
*In the body section,
(A) create frames in html with two columns
(B)Open the files left.html and right.html in different frames
LEFT.HTML
1.create another new file and put the normal html tags in the file
2.type the contents in the file for the first columns in the frames
RIGHT.HTML
1.create another new file and put the normal html tags in the file
2.type the contents in the file for the first columns in the frames
3.the second column it displays , “this is my second frame”
4.After using the first column in frames the webpage will be displayed.
Program:
DEFAULT.HTML:
<html>
<head>
<title>
RadioButton_Using_Website
</title>
</head>
<frameset cols=50%,50%>
<frame name=left src=left.html>
<frame name=right src=right.html>
</frameset>
</html>
LEFT.HTML:
<html>
<body bgColor="ivory">
<p>
<b>
Choose the Website Using Radio Button
</b>
</p>
<input type="radio" name="optwebsite" language="VbScript"
onClick="cmd1('Google') ">Google<BR>
<input type="radio" name="optwebsite" language="VbScript"
onClick="cmd2('Yahoo')">Yahoo<BR>
<input type="radio" name="optwebsite" language="VbScript"
onClick="cmd3('Rediff') ">Rediff<BR>
<script language="VbScript">
sub cmd1(web)
window.parent.frames(1).location.href="google.html"
end sub
sub cmd2(web)
window.parent.frames(1).location.href="yahoo.html"
end sub
sub cmd3(web)
window.parent.frames(1).location.href="rediff.html"
end sub
</script>
</body>
</html>
RIGHT.HTML:
<html>
<body><center>
THIS IS THE BLANK PAGE IN THE RIGHT FRAME
</center>
</body>
</html>
GOOGLE.HTML:
<html>
<body>
<h1>
<a href="http://www.google.co.in/">Google</a>
</h1>
</body>
</html>
YAHOO.HTML:
<html>
<body>
<h1>
<a href="http://in.yahoo.com/">Yahoo</a>
</h1>
</body>
</html>
REDIFF.HTML:
<html>
<body>
<h1>
<a href="http://www.rediff.com/">Rediff</a>
</h1>
</body>
</html>
OUTPUT:
FRAMES(vbscript)
DEFAULT.HTML:
<html>
<head>
<title>
Radio button_using_website
</title>
</head>
<Frameset cols=50%,50%>
<Frame Name=left src="left.html">
<Frame Name=right src="right.html">
</Frameset>
</html>
LEFT.HTML:
<HTML>
<BODY>
<SCRIPT LANGUAGE="javascript">
function loadURL(url)
{
window.parent.frames[1].location=url
}
</SCRIPT>
<H3 align=center>
<u>
<b>
Please click one of the following to get a search engine
</b>
</u>
</H3>
<FORM NAME="searchForm">
<INPUT TYPE=radio NAME=engine
onClick="loadURL('http://www.google.co.in/')">Google<BR>
<INPUT TYPE=radio NAME=engine onClick="loadURL('http://in.yahoo.com/')"
>Yahoo<BR>
<INPUT TYPE=radio NAME=engine
onClick="loadURL('http://www.ask.com/')">Ask<BR>
</FORM>
</BODY>
</HTML>
RIGHT.HTML:
<HTML>
<BODY>
<center>
THIS IS THE BLANK PAGE IN THE RIGHT FRAME
</center>
</BODY>
</HTML>
OUTPUT:
Result:
Thus the form has been created with two frames side by side and loads the search
engine.
EMPLOYEE DATABASE
Aim:
To create an employee database and manipulate the commands.
Procedure:
1.create a new file and put the normal html document structure tags.
2.In the head section specify the title of the webpage
3.specify the script type of javascript
4.Assign special character to the variable file
5.the client whether the contents of the database is valid in forms
6.save the file and run it in internet explorer.
Program:
<html>
<head>
<title> Employee database</title>
<script language="javascript">
function set(forms)
{
document.forms[0].elements[0].focus(" ");
}
function check_empty()
{
for(i=0;i<=9;i++)
{
if(document.forms[0].elements[i].value="")
{
alert("Please fill in the document",forms[0].elements[i].name+"field");
document.forms[0].elements[i].focus();
return(false);
}
}
}
function check_len()
{
for(i=1;i<=3;i++)
{
var name=document.forms[0].elements[i].value;
len=name.length;
if(len>15)
{
alert("value exceeds is characters");
document.forms[0].elements[i].value=" ";
document.forms[0].elements[i].focus();
}
}
}
function validate_pay()
{
if(pay==0)
{
alert("please enter proper pay");
doucment.forms[0].elements[i].value=" ";
document.forms[0].elements[i].focus();
return(false);
}
}
function calculate()
{
forms.da.value=parseFloat(forms.bp.value)*0.50;
forms.hra.value=parseFloat(forms.bp.value)*0.12;
forms.gp.value=parseFloat(forms.bp.value)+parseFloat(forms.da.value)+parseFloa
t(forms.hra.value);
forms.pf.value=parseFloat(forms.bp.value)*0.9;
forms.np.value=parseFloat(forms.gp.value)-parseFloat(forms.pf.value);
}
</script>
</head>
<body bgcolor="ivory" onLoad="set(this.forms)">
<h1 align="center">
<u>
Employee Database Validation</u>
</h1>
<br>
<form name=forms onSubmit="return check_empty()"><pre>
Employee number:<input type="text" name=eno size=15 ><br>
Employee name:<input type="text" name=ename size=15 maxlength=15
onBlur="check_len()"><br>
Designation:<input type="text" name=desi size=15 maxlength=15
onBlur="check_len()"><br>
Department:<input type="text" name=dep size=15 maxlength=15
onBlur="check_len()"><br>
Basic pay:<input type="text" name=bp size=15 maxlength=15
onBlur="validate_pay()"><br>
Dearness Allowance:<input type="text" name=da size=15
onFocus="calculate()"><br>
House Rent Allowance:<input type="text" name=hra size=15><br>
Gross Pay:<input type="text" name=gp size=15><br>
Provident Fund:<input type="text" name=pf size=15><br>
Net pay:<input type="text" name=np size=15><br></pre><center>
<input type="submit" name=b1 value="submit">
<input type="reset" name=b2 value="clear">
</center>
</form>
</body>
</html>
Result:
Thus an employee database has been manipulated using javascript.
EMPLOYEE DATABASE USING COMMAND OBJECT
Aim:
To create an employee database and manipulate the records using command object in
asp.
Procedure:
 Start programs  microsoft visual studio 2005.
 File  new website  asp.net  ok.
 Binary the data grid control in control default aspx file.
 Goto the design page and double click the page.
 Write the command object in the load event in the default .aspx vbfile.
 Then start will run in the internet explorer.
Data Flow Diagram:
Gross
pay
Net
pay
calculate
Ename
HR
Employee Details
Eno
DA
pf
Program:
INDEX.ASPX
SOURCE:
<%@ Page Language="VB"%>
<html>
<head runat="server">
<title>EMPLOYEE DATABASE</title>
</head>
<body>
<form id="form1" runat="server">
Basic
pay
<div>
<asp:DataGrid ID = "dgDisplay" runat="Server" AutoGenerateColumns="false"
AllowSorting="true"
OnSortCommand ="Sort_Grid"
OnItemCommand ="Click_Grid" >
<Columns>
<asp:HyperLinkColumn HeaderText="ID (Click for more Info)"
DataNavigateUrlField = "EmpID"
DataNavigateUrlFormatString ="./View.aspx?EmpID={0}" DataTextField ="EmpID"
SortExpression ="EmpID">
</asp:HyperLinkColumn>
<asp:BoundColumn DataField = "EmpID" Visible="false">
</asp:BoundColumn>
<asp:BoundColumn HeaderText="Employee Name"
DataField ="EmpName">
</asp:BoundColumn>
<asp:BoundColumn HeaderText="Department"
DataField ="Department">
</asp:BoundColumn>
<asp:BoundColumn HeaderText="Salary"
DataField ="Salary">
</asp:BoundColumn>
<asp:ButtonColumn HeaderText ="Click to Edit"
ButtonType = "PushButton" Text="Edit" CommandName="Edit">
</asp:ButtonColumn>
<asp:ButtonColumn HeaderText ="Click to Delete"
ButtonType = "PushButton" Text="Delete" CommandName ="Delete">
</asp:ButtonColumn>
</Columns>
</asp:DataGrid>
<asp:HyperLink ID="Hyp1" runat="server" NavigateUrl="~/Add.aspx">
Click to Add an Employee
</asp:HyperLink>
</div>
</form>
</body>
</html>
DESIGN:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
Dim DBConn As Data.OleDb.OleDbConnection
Dim DBCommand As Data.OleDb.OleDbDataAdapter
Dim DSPage As New Data.DataSet
DBConn = New
Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;"& "DATA
SOURCE="& Server.MapPath("/Employee/EmployeeDB.mdb;"))
DBCommand = New Data.OleDb.OleDbDataAdapter("Select * from Emp",
DBConn)
DBCommand.Fill(DSPage, "Emp")
dgDisplay.DataSource = DSPage.Tables("Emp").DefaultView
dgDisplay.DataBind()
End If
End Sub
SORT_GRID:
Sub Sort_Grid(ByVal Sender As Object, ByVal E As
DataGridSortCommandEventArgs)
Dim DBConn As Data.OleDb.OleDbConnection
Dim DBCommand As Data.OleDb.OleDbDataAdapter
Dim DSPage As New Data.DataSet
DBConn = New
Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;"& "DATA
SOURCE=" & Server.MapPath("/Employee/EmployeeDB.mdb;"))
DBCommand = New Data.OleDb.OleDbDataAdapter("Select * from Emp Order By"
& E.SortExpression.ToString(), DBConn)
DBCommand.Fill(DSPage, "Emp")
dgDisplay.DataSource = DSPage.Tables("Emp").DefaultView
dgDisplay.DataBind()
End Sub
CLICK_GRID:
Sub Click_Grid(ByVal Sender As Object, ByVal E As
DataGridCommandEventArgs)
If E.CommandName = "Edit" Then
Response.Redirect("./Edit.aspx?EmpID=" & E.Item.Cells(1).Text)
ElseIf E.CommandName = "Delete" Then
Dim DBConn As Data.OleDb.OleDbConnection
Dim DBDelete As New Data.OleDb.OleDbCommand
Dim DBCommand As Data.OleDb.OleDbDataAdapter
Dim DSPage As New Data.DataSet
DBConn = New
Data.OleDb.OleDbConnection("PROVIDER=
Microsoft.Jet.OLEDB.4.0;"& "DATA SOURCE=" &Server.MapPath
("/Employee/EmployeeDB.mdb;"))
DBDelete.CommandText = "Delete from emp Where EmpID="&
E.Item.Cells(1).Text
DBDelete.Connection = DBConn
DBDelete.Connection.Open()
DBDelete.ExecuteNonQuery()
DBCommand = New Data.OleDb.OleDbDataAdapter("Select * from
Emp", DBConn)
DBCommand.Fill(DSPage, "Emp")
dgDisplay.DataSource = DSPage.Tables("Emp").DefaultView
dgDisplay.DataBind()
End If
End Sub
VIEW.ASPX
SOURCE:
<%@ Page Language="VB"%>
<html>
<head runat="server">
<title>EMPLOYEE DATABASE
</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="EmpID" runat ="server" >
</asp:Label>
<asp:Label ID="EmpName" runat="server" >
</asp:Label>
<asp:Label ID="Dept" runat="server" >
</asp:Label>
<asp:Label ID="Salary" runat="server" >
</asp:Label>
<asp:HyperLink ID="HyperLink1" runat="server" Text = "Return to Grid"
NavigateUrl = "~/Index.aspx">
Return to Grid
</asp:HyperLink>
</div>
</form>
</body>
</html>
DESIGN:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim DBConn As Data.OleDb.OleDbConnection
Dim DBCommand As Data.OleDb.OleDbDataAdapter
Dim DSPage As New Data.DataSet
If Len(Request.QueryString("EmpID")) = 0 Then
Response.Redirect("./Default.aspx")
End If
DBConn = New
Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;"& "DATA
SOURCE=" & Server.MapPath("/Employee/EmployeeDB.mdb;"))
DBCommand = New Data.OleDb.OleDbDataAdapter("Select * from Emp where
EmpID="& Request.QueryString("EmpID"), DBConn)
DBCommand.Fill(DSPage, "Emp")
EmpID.Text = "Employee ID: " & DSPage.Tables("Emp").Rows(0).Item("EmpID")
EmpName.Text = "Employee Name: " &
DSPage.Tables("Emp").Rows(0).Item("EmpName")
Dept.Text = "Department: " & DSPage.Tables("Emp").Rows(0).Item("Department")
Salary.Text = "Salary: " & DSPage.Tables("Emp").Rows(0).Item("Salary")
End Sub
ADD.ASPX
SOURCE:
<%@ Page Language="VB"%>
<html>
<head runat="server">
<title>EMPLOYEE DATABASE </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="EID" runat="server"
Text="Employee ID">
</asp:Label>
<asp:TextBox ID="EmpID" runat="server">
</asp:TextBox>
<asp:Label ID="EName" runat="server"
Text="Employee Name">
</asp:Label>
<asp:TextBox ID="EmpName" runat="server">
</asp:TextBox>
<asp:Label ID="Dep" runat="server" Text="Department">
</asp:Label>
<asp:TextBox ID="Dept" runat="server">
</asp:TextBox>
<asp:Label ID="Sal" runat="server" Text="Salary">
</asp:Label>
<asp:TextBox ID="Salary" runat="server">
</asp:TextBox>
<asp:Button ID="OK" runat="server" Text=" ADD " />
<asp:HyperLink ID="HyperLink1" runat="server" Text="Return"
NavigateUrl="~/Index.aspx">
Return to Grid
</asp:HyperLink>
</div>
</form>
</body>
</html>
DESIGN:
OK:
Protected Sub OK_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim DBConn As Data.OleDb.OleDbConnection
Dim DBInsert As New Data.OleDb.OleDbCommand
DBConn = New
Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;"& "DATA
SOURCE=" & Server.MapPath("/Employee/EmployeeDB.mdb;"))
DBInsert.CommandText = "Insert into Emp (EmpID, EmpName, Department, Salary)
values(" _& "'" & Replace(EmpID.Text, "'", "''")
& "', " _& "'" & Replace(EmpName.Text, "'", "''") & "', " _& "'" &
Replace(Dept.Text, "'", "''") & "', " _& "'" &
Replace(Salary.Text, "'", "''") & "')"
DBInsert.Connection = DBConn
DBInsert.Connection.Open()
DBInsert.ExecuteNonQuery()
Response.Redirect("./Index.aspx")
End Sub
EDIT.ASPX
SOURCE:
<%@ Page Language="VB"%>
<html>
<head runat="server">
<title>EMPLOYEE DATABASE</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="EID" runat="server"
Text="Employee ID">
</asp:Label>
<asp:TextBox ID="EmpID" runat="server">
</asp:TextBox>
<asp:Label ID="EName" runat="server"
Text="Employee Name">
</asp:Label>
<asp:TextBox ID="EmpName" runat="server">
</asp:TextBox>
<asp:Label ID="Dep" runat="server" Text="Department">
</asp:Label>
<asp:TextBox ID="Dept" runat="server">
</asp:TextBox>
<asp:Label ID="Sal" runat="server" Text="Salary">
</asp:Label>
<asp:TextBox ID="Salary" runat="server">
</asp:TextBox>
<asp:Button ID="OK" runat="server" Text=" UPDATE " />
<asp:HyperLink ID="HyperLink1" runat="server" Text="Return"
NavigateUrl="~/Index.aspx">
Return to Grid
</asp:HyperLink>
</div>
</form>
</body>
</html>
DESIGN:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Len(Request.QueryString("EmpID")) = 0 Then
Response.Redirect("./index.aspx")
End If
If Not IsPostBack Then
Dim DBConn As Data.OleDb.OleDbConnection
Dim DBCommand As Data.OleDb.OleDbDataAdapter
Dim DSPage As New Data.DataSet
DBConn = New Data.OleDb.OleDbConnection("PROVIDER=" &
"Microsoft.Jet.OLEDB.4.0;" & "DATA SOURCE=" &
Server.MapPath("/Employee/EmployeeDB.mdb;"))
DBCommand = New Data.OleDb.OleDbDataAdapter("Select * from Emp where
EmpID = " _& Request.QueryString("EmpID"), DBConn)
DBCommand.Fill(DSPage, "Emp")
EmpID.Text = DSPage.Tables("Emp").Rows(0).Item("EmpID")
EmpName.Text = DSPage.Tables("Emp").Rows(0).Item("EmpName")
Dept.Text = DSPage.Tables("Emp").Rows(0).Item("Department")
Salary.Text = DSPage.Tables("Emp").Rows(0).Item("Salary")
End If
End Sub
OK:
Protected Sub OK_Click(ByVal Sender As Object, ByVal E As System.EventArgs)
Dim DBConn As Data.OleDb.OleDbConnection
Dim DBUpdate As New Data.OleDb.OleDbCommand
DBConn = New Data.OleDb.OleDbConnection("PROVIDER=" &
"Microsoft.Jet.OLEDB.4.0;" & "DATA SOURCE=" &
Server.MapPath("/Employee/EmployeeDB.mdb;"))
DBUpdate.CommandText = "Update Emp set " _
& "EmpName = " _
& "'" & Replace(EmpName.Text, "'", "''") & "', " _
& "Department = " _
& "'" & Replace(Dept.Text, "'", "''") & "', " _
& "Salary = " _
& "'" & Replace(Salary.Text, "'", "''") & "'" _
& " Where " _
& "EmpId = " & Request.QueryString("EmpId")
DBUpdate.Connection = DBConn
DBUpdate.Connection.Open()
DBUpdate.ExecuteNonQuery()
Response.Redirect("./Index.aspx")
End Sub
OUTPUT:
INDEX.ASPX
ADD.ASPX
VIEW.ASPX
EDIT.ASPX
Result:
Thus an asp application for online has been created and the output has been
verified.
REQUEST AND RESPONSE OBJECTS
Aim:
To develop an illustration to the usage of request and response objects in asp.
Procedure:
1.Bring 2 buttons and 1 label in the design page of default.aspx, change the text of
buttons using properties window.
2. double click on the write button and response the code for writing the cookies
using response objects.
3. double click on the read button and response the code for writing the cookies
using request objects
4. Run the file using the play button.
Data flow Diagram
REQUEST
WRITE
COOKIE
READ COOKIE
RESPONSE
Program:
SOURCE:
<%@ Page Language="VB" %>
<html>
<head >
<title>REQUEST AND RESPOND</title>
</head>
<body><b><U>REQUEST AND RESPOND</U></b>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Read_Cookie" />
<asp:Button ID="Button2" runat="server" Text="Write_Cookie" />
</div>
</form>
</body>
</html>
DESIGN:
Read_Cookie:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim I As Integer
For I = 0 To Request.Cookies.Count - 1
Label1.Text = Label1.Text & Request.Cookies.Item(I).Name & "->" &
Request.Cookies.Item(I).Value & "<br>"
Next
End Sub
Write_Cookie:
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Cookies("COOKIE1").Expires = "5/1/2012"
Response.Cookies("COOKIE1").Value = "I AM COOKIE ONE"
Response.Cookies("COOKIE2").Expires = "5/1/2012"
Response.Cookies("COOKIE2").Value = "I AM COOKIE TWO"
End Sub
OUTPUT:
Result:
Thus an application has been created for request and response objects in asp.
LIST OF HEADERS USING REQUEST OBJECT
Aim:
To write an asp program using request object to give the exact list of header sent
by the browser to the web browser.
Procedure:
1.create a website using vb 2005
2.bring one label to the design page of default aspx file.
3.double click on the page and write the code using request objects display the
header in the page load event.
4.save the website and run it using play button.
Data Flow Diagram
REQUEST
OBJECT
HEADER
Program:
SOURCE:
<%@ Page Language="VB" %>
<html>
<head>
<title> HEADERS USING REQUEST OBJECT
</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
DESIGN:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer
Label1.Text = "<table>"
For i = 0 To Request.Headers.Count - 1
Label1.Text = Label1.Text & "<tr><td><b>" & Request.Headers.GetKey(i) &
"</b></td><td>" & Request.Headers(i) & "</td><tr>"
Next
Label1.Text = Label1.Text & "</table>"
End Sub
OUTPUT:
Result:
Thus an asp program using request object for headers has been created and
output has been verified.
STUDENT DATABASE
Aim:
To write a program in asp to display the records one by one from a student
database.
Procedure:
1. Start->programs->ms visual studio 2005
2. File->new->website->asp.net->ok
3. Bring the datagrid control in default aspx file
4. Create the table in the access
5. Copy the acess database in the app_data of website which we created student
database
6. Connect the access datasource control to the asp.net by bringing the
datasource control and change the property of access datasource
7. Save the website and run it in the internet explorer
Data Flow Diagram
Student details
SNO
SNAME
SUB1
SUB2
SUB3
calculate
TOTAL
AVERAGE
Program:
SOURCE:
<%@ Page Language="VB" %>
<html>
<head>
<title>STUDENT DATABASE</title>
</head>
<body><b><u>STUDENT DATABASE</u></b>
<form id="form1" runat="server">
<div>
<asp:DataGrid ID="dg1" runat="server"></asp:DataGrid>
<asp:Button ID="Button1" runat="server" Text="CALCULATE" />
SUB4
</div>
</form>
</body>
</html>
DESIGN:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim dbcon As Data.OleDb.OleDbConnection
Dim dbcom As Data.OleDb.OleDbDataAdapter
Dim STUD As New Data.DataSet
dbcon = New
Data.OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" &
"DATA SOURCE=" & Server.MapPath("\Program5\App_Data\STUD.mdb;"))
dbcom = New Data.OleDb.OleDbDataAdapter("select * from STUDENT", dbcon)
dbcom.Fill(STUD, "STUDENT")
dg1.DataSource = STUD.Tables("STUDENT").DefaultView
dg1.DataBind()
End Sub
CALCULATE:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer
For i = 0 To 4
dg1.Items(i).Cells(7).Text = Val(dg1.Items(i).Cells(3).Text) +
Val(dg1.Items(i).Cells(4).Text) + Val(dg1.Items(i).Cells(5).Text) +
Val(dg1.Items(i).Cells(6).Text)
dg1.Items(i).Cells(8).Text = Val(dg1.Items(i).Cells(7).Text) / 4
Next
End Sub
OUTPUT:
Result:
Thus an asp application for online has been created and the output has been
verified.
ONLINE BOOKSHOP
Aim:
To write program in Asp to display the records of books in the online bookshop
using Addrotator components.
Procedure:
 Create a website visual studio 2005.
 Being four labels and four text boxes in the design page labels and four text
boxes.
 In the design page of the default asp and bring one button in design page.
 Double click the button & write the response redirect in the click event of
button.
 The response redirect object opens the new window which has been another
aspx file.
 The another aspx file contains addrotater component which also have
advertisement.
 Add a xml file to the existing website and link the image url.
 Save the file and run it using play button.
Data Flow Diagram
ONLINE
BOOKSHOP
BOOK NAME
AUTHOR
NAME
PURCHASE
BOOK
PRICE
Program:
HOME.ASPX:
SOURCE:
<%@ Page Language="VB"%>
<html>
<head>
<title>ONLINE BOOKSHOP
</title>
</head>
<body><b>ONLINE BOOKSHOP</b>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="BOOK NAME" Width="112px">
</asp:Label>
<asp:TextBox ID="TextBox1" runat="server">
</asp:TextBox>
<asp:Label ID="Label2" runat="server" Text="AUTHOR NAME">
</asp:Label>
<asp:TextBox ID="TextBox2" runat="server">
</asp:TextBox>
<asp:Label ID="Label3" runat="server" Text="BOOK PRICE" Width="112px">
</asp:Label>
<asp:TextBox ID="TextBox3" runat="server">
</asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="PURCHASE" />
</div>
</form>
</body>
</html>
DESIGN:
PURCHASE:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Redirect("purchase.aspx")
End Sub
PURCHASE.ASPX:
SOURCE:
<%@ Page Language="VB" %>
<html>
<head>
<title>ONLINE BOOKSHOP</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Thank You For Purchasing"
Width="208px"></asp:Label>
<asp:AdRotator ID="AdRotator1" runat="server"
AdvertisementFile="~/adrotate.xml"/>
</div>
</form>
</body>
</html>
ADROTATE.XML:
SOURCE:
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl> .\book.jpg </ImageUrl>
<AlternateText> BookShop </AlternateText>
<Impressions> 5 </Impressions>
</Ad>
<Ad>
<ImageUrl> .\book1.jpg </ImageUrl>
<AlternateText> BookShop1 </AlternateText>
<Impressions> 5 </Impressions>
</Ad>
</Advertisements>
OUTPUT:
Result:
Thus an asp application for online has been created and the output has been
verified.
MOUSE CLICK USING LINK BUTTON
Aim
To create a Asp.net program to create a mouse click event using link button.
Procedure
1. In the source area place a image button and also place a link button.
2. Write the codings in the <div> tag
3. Place the label button and double click that and type the codings.
4.Finally, the mouse click using link button is created.
Data Flow Diagram
click
BUTTON
LOADING IMAGE
Program
Source
<html>
<body>
<form runat =”server”>
<asp:linkButton ID = “click” Text=”click me” Onclick=”submitbtn_click”/>
<p>
<asp:Label ID=”label1” runat=”server”/>
</p>
</body>
</html>
Design:
Sub submitbtn_click(sender As object, e As EventArgs)
Label.Text=”you clicked the LinkButton control”
End sub
OUTPUT:
MOUSE CLICK USING IMAGE BUTTON
Aim:
To write a Asp.net program to create a mouse click event using image button.
Procedure:
1. In the source area place a image button .
2. Write the codings in the <div> tag.
3. Place the label button and double click that and type the codings.
4.Finally, the mouse click using link button is created.
Program
Source
<html>
<body>
<form id=”form1” runat =”server”>
<h3>ImgButton sample</h3>
Click anywhere on the image<br>
<asp:imageButton ID = “ImageButton runat”server”
AlternateText=”ImageButton1”ImageAlign=”left” ImageUrl=”`/winter.jpg”
Onclick=”Imagebutton_click”/>
<br>
<br>
<asp:label id = “label1 runat=”server”/>
</form>
</body>
</html>
Design:
Sub Imagebutton_click (sender As object, e As EventArgs)
Label.Text=”you clicked the ImageButton control at the
coordinates(”&e.X.Tostring()&”,”&e.Y.ToString() &”)”
End sub
Output
LOGIN PAGE EXPIRE
SOURCE:
PAGE1.html
<HTML>
<HEAD>
<TITLE>Unload Exercise </TITLE>
</HEAD>
<BODY BGCOLOR="#E1F0FF">
<FONT SIZE="4" COLOR="#000033" face="tahoma"> <B>This Page Unloads
itself after 1 Minute.</B></FONT>
</BODY>
</HTML>
DESIGN:
<%@ Page Language="VB" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<html >
<head runat="server">
<title>Login Page Expire Exercise</title>
</head>
<body>
<form id="form1" runat="server">
<div style="margin-left: 80px">
<br /> <b>User Name : </b>    
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br /> <b>Password    : </b>    
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br /> <br />
           
<asp:Button ID="Button1" runat="server" Text="Login" /> <br /> <br />
<br /> <br />
</div>
<p> </p>
</form>
</body>
<Script>
function sessionHasExpired()
{
if(confirm("Your session has expired. You will be redirected to Home page. ")){
window.location = "http://google.com/?q=login";
}
}
var sessionTimeInMilliseconds = 100000;
setTimeout(sessionHasExpired, sessionTimeInMilliseconds );
</script>
</html>
UNLOAD.ASPX
<%@ Page Language="VB" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication3._Default" %>
<html >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
<script>
window.open('d:/page1.html','winname','directories=no,titlebar=no,toolbar=no,locatio
n=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=350');
Page.unload();
</script>
</body>
<Script>
protected override void OnUnload(EventArgs e)
{
base.OnUnload(e);
if(confirm("Your page shall be uloaded now. ")){
window.location = "http://google.com/?q=login";
}
}
</Script>
</html>
PASSWORDCACHE.ASPX
%@ Page Language="asp" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebApplication4._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">
<div>
<asp:label id="Label1" runat="server">UserName:</asp:label>   
<asp:textbox id="tbName" runat="server" Width="183px"></asp:textbox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="tbName" ErrorMessage="Please Input
UserName!!!"></asp:RequiredFieldValidator><br />
<br />
<asp:label id="Label2" runat="server" Width="78px">PassWord:</asp:label>
<asp:textbox id="tbPass" runat="server" Width="183px"></asp:textbox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="tbPass" ErrorMessage="Please Input
PassWord!!!"></asp:RequiredFieldValidator><br />
<br />
<asp:Button ID="btnLoginBetter" runat="server" OnClick="btnLoginBetter_Click"
Text="Login" Width="99px" /><br />
<br />
<asp:Label ID="lbUser" runat="server" Width="286px"></asp:Label>
<script>
Imports System.Web.Caching
Partial Class UseCacheVB
Inherits System.Web.UI.Page
Protected Sub btnLoginBetter_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim sKey As String = tbName.Text + "_IsLogin"
Dim sUser As String = Convert.ToString(Cache(sKey))
If sUser = Nothing Or sUser = String.Empty Then
Dim SessTimeOut As New TimeSpan(0, 0, 1, 0, 0)
HttpContext.Current.Cache.Insert(sKey, sKey, Nothing, DateTime.MaxValue,
SessTimeOut, CacheItemPriority.NotRemovable, Nothing)
lbUser.Text = "Hello!Welcome"
Else
lbUser.Text = "Sorry,try again in one minutes"
Return
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
End Sub
End Class
</script>
</div>
</form>
</body>
</html>
OUTPUT:
NO TOOLBAR,SCROLL BAR, STATUS BAR,MENU BAR
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebApplication7._Default" %>
<html>
<head runat="server">
<title>Untitled Page</title>
</head>
<BODY BGCOLOR="#E1F0FF">
<form id="form1" runat="server">
<div>
<FONT SIZE="4" COLOR="#000033" face="tahoma"> <B>This Page Unloads
itself after 1 Minute.</B></FONT>
</div>
</form>
<script>
// Close this window after 10 seconds.
window.setTimeout(CloseMe, 10000);
function CloseMe() {
if(confirm("This page shall be unloaded now. ")){
self.close();
}
}
</script>
</body>
</html>
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebApplication7._Default" %>
<html >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
<script>
window.open('page1.aspx','winname','directories=no,titlebar=no,toolbar=no,location=
no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=350');
</script>
</body>
</html>
Download