0% found this document useful (0 votes)
13 views116 pages

Web Technology Practical

Uploaded by

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

Web Technology Practical

Uploaded by

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

EX.

NO:1
FIBONACCI SERIES
DATE:

AIM:
To write a JavaScript program to find fibonacci series.
PROCEDURE:
1. Open the notepad and type the program.
2. Declare the variables.
3. By using prompt () method displays a dialog box that prompts the user for input.
4. After entering an input value the user will have to click “ok” or “cancel” to proceed.
5. If the user clicks “ok” the box returns input value. If the user clicks “ cancel” the box returns null.
6. The parseInt () method parses a value as a string and return the integer.
7. To print statements the following methods were used.
Document.write () does not add a new line after each statement
Document.writeln () add a new line after each statement
8. Using for loop find Fibonacci series.
9. Save the program as Fibonacci.html.
10. Finally run the program though browser.

1
PROGRAM:
<html>
<body>
<h1>*****fibonacci series*****</h1>
<script>
var n1=0,n2=1,n3,i;
var num=parseInt (prompt("enter the limit of fibonacci series"));
document.writeln("fibonacci series is:");
document.writeln("<br>"+n1);
document.writeln("<br>"+n2);
for(i=3;i<=num;i++)
{
n3=n1+n2;
document.writeln("<br>"+n3);
n1=n2;
n2=n3;
}
</script>
</body>
</html>

2
OUTPUT:

3
RESULT:
Thus the program was executed successfully.

4
EX.NO:2
PALINDROME
DATE:

To write a JavaScript program to check the given string is palindrome or not.


PROCEDURE:
1. Open the notepad and type the program.
2. Declare the variables.
3. By using prompt () method displays a dialog box and get the input from the user.
4. Store the string in the variable given string.
5. By using split()method split the string into an array of substrings.
6. By using reverse(0 method reverse the order of elements in the array.
7. By using join() method return the array of substrings as a string.
8. Store the string in the variable final string.
9. If the given string is equal to final string display “the string is palindrome”.
10. Otherwise display “the string is not palindrome”.
11. Save the program as palindrome.html.
12. Finally run the program through browser.

5
PROGRAM:
<html><body>
<h1>****check palindrome or not****</h1>
<script>
function palindrome()
{
var givenstring=prompt("enter the string:");
document.writeln("<br>"+"the givenstring is:",givenstring);
var arraystring=givenstring.split('');
document.writeln("<br>"+"the split()string is :",arraystring);
var reversestring=arraystring.reverse();
document.writeln("<br>"+"the reverse()string is:",reversestring);
var finalstring=reversestring.join('');
document.writeln("<br>"+"the join()string is:",finalstring);
document.writeln("<br>");
if(givenstring==finalstring)
{document.writeln("<br>"+"the string is palindrome");}
else
{
document.writeln("<br>"+"the string is not palindrome");
}}
palindrome();
</script>
</body></html>

6
OUTPUT:

7
8
RESULT:
Thus the program was executed successfully.

9
EX.NO:3 FORM VALIDATION

DATE:

AIM:

To Write a JavaScript program to perform the form validation.


PROCEDURE:
1. Open the notepad and type the program.
2. In body tag create the form tag with two attributes action and on submit.
3. The action attribute redirect the html page to another when a form is submitted.
4. The on submit attribute is used to execute the specified code when the form is submitted. In this program
which execute check() function.
5. The check() function will stop executing when the return statement is called. the return statement should
be the last statement in a function because the code after the return statement will not reachable.
6. Write the definition for check() function in script tag.
7. One of the most used from element is <input>element. It can be displayed in several ways depending on
the type attribute.
8. Declare the variables and get the values for the variables using document. getElementById(). value
method
9. If the variable un or pwd becomes null return false otherwise return true and the address.html file will be
open using action attribute.
10. Save the program as form validation.html
11. Finally run the program through browser.

10
PROGRAM:
<html>
<head>form validation</head>
<body>
<form name="login">
username<input type="text"name="userid"/>
password <input type="password"name="pswrd"/>
<input type="button"onclick="check(this.form)"value="login"/>
<button type="reset"value="Reset">Reset</button>
</form>
<script language="javascript">
function check(form)
{
if(form.userid.value=="kaleeswari"&& form.pswrd.value=="c0s39951")
{
alert("registered your password or username")
}
else
{
alert("error password or username")
}
}
</script>
</body>
</html>

11
OUTPUT:

12
13
RESULT:
Thus the program was executed successfully.

14
EX:NO:04
POPUP WINDOW CREATION
DATE:

AIM:
To write a JavaScript program to create popup window.
PROCEDURE:
1. Open the notepad and type the program
2. JavaScript has three kind of popup boxes: alert box, confirm box and prompt box
3. An alert box is used to give a message to the users, when an alert box pops up, the user have to click “ok”
to proceed.
4. A confirm box is used if you want the user to verify or accept something. when a confirm box pops up,
the user click either “ok” or “cancel” to proceed.
5. If the user click “ok”, the box return true. If the user clicks “cancel”, the box return false.
6. A prompt box is used if you want the user to input a value before entering a page. When a prompt box
pops up, the user will have to click either “ok” or “cancel” to proceed after entering an input value.
7. If the user clicks ok the box return the input value. If the user clicks cancel the box return null.
8. The on click event occurs when the user clicks any one of two buttons. In this event the function1() or
function2() is called and executed.
9. Save the program as popup.html.
10. Finally run the program through browser.

15
PROGRAM:
<html>
<body>
<h1>*****confirm box alert box prompt box******</h1>
<button onclick="function1()">"to know the confirm box try if"</button>
<button onclick="function2()">"to know the prompt box try if"</button>
<script>
function function1()
{
if(confirm("press the putton"))
{
alert("ok");
}
else
{
alert("cancal");
}
}
function function2()
{
var user=prompt("enter the user name");
if(user=="admin")
{
alert("login succesfully");
}
else
{
alert("login failed");
}
}
</script>
</body>
</html>
16
OUTPUT:

17
18
RESULT:
Thus the program was executed successfully.

19
EX:NO:5
EVENT HEADLER

DATE:

AIM:
To write a JavaScript program to handle events.

PROCEDURE:
1. Open the notepad and type the program.
2. The onmuseover event occurs when mouse pointer is moved on to an element<p>. in this event the
function f1() is called.
3. The onfocus event occurs when an element get focus. Which is most often used with<input>.in this event
the function f2() is called.
4. The onclick event occurs when the user clicks on an element. In this event the function f3() is called.
5. The onkeydown event occurs when a key is pressed. In this event the function f4() is called.
6. Save the program as event.html.
7. Finally run the program through browser.

20
PROGRAM:
<html>
<head>
<script>
function f1()
{
alert("on mouse event");
}
function f2()
{
document .getElementById("text1").style.background="red";
}
function f3()
{
alert("I am a programmer");
}
function f4()
{
alert("you pressed the key");
}
</script>
</head>
<body>

<h1>JAVASCRIPT EVENTS</H1>
<form action ="address.html">
<p onmouseover="f1()">Keep cursor me</p>
<br>
<br>
enter your name :<input type="text"id="text1"onfocus="f2()">
<br>
<br>
<input type="button"onclick="f3()"value=" i am click here to know who am i">
21
<br>
<br>
enter something here:<input type="text"onkeydown="f4()">
<br>
<br>
<button type=submit>submit</button>
</from>
</body>
</html>

22
OUTPUT:

23
24
RESULT:
Thus the program was executed successfully
25
EX.NO:6
DROP DOWN LIST
DATE:

AIM:
To write a JavaScript program to remove items from dropdown list.

PROCEDURE:
1. Open the notepad and type the program.
2. Create a drop-down list with 5 options.
3. The <select>element is used to create a drop-down list.
4. The<option> tags inside the <select> element define the available options in the drop-down list .
5. The onclick event occurs when the user clicks remove button. In this event the function item() is called.
6. In the item(0 function declare the variable and get the value for the variable by
document.getElementById() method which return an element with a specified value.
7. The selectedIndex property sets or returns the index of the selected option in drop-down list and the index
starts at(0.
8. The remove() method removes the selected element.
9. Save the program as dropdown.html.

10.Finally run the program through browser.

PROGRAM:
<html>
26
<head>
<script>
function item()
{
var c=document.getElementById("color");
c.remove(c.selecteIndex);
}
</script>
</head>
<body>
<h1>****remove items from drop down list****</h1>
<select id="color">
<option>red</option>
<option>blue</option>
<option>green</option>
<option>purple</option>
<option>yellow</option>
</select>
<input type="button"onclick="item()"value="remove">
</body>
</html>

27
OUTPUT:

28
RESULT:
Thus the program was executed successfully.

29
EXNO:7
DISPLAY A RANDOM IMAGE
DATE:

AIM:
To write a JavaScript program to display a random image.

PROCEDURE:
1. Open the notepad and type the program.
2. The onclick event occurs when the user click button. In this event function.
selInterval(randomimage,2000)is called.
3. The setInterval() method calls a function random image at specified intervals(in
milliseconds).2second=2000 milliseconds.
4. In randomimage() method create an array of four images, and stuff it into the variable r
5. The variable number gets the value of a math expression.
6. Math.random generates a random number between 0 and 1,which is multiplied by r.length, which is the
number of items in the array (in this case, it’s 4). Math.floor rounds the result down to an integer.
7. The source of the image result is set based on the array r, and the value at this moment is dependent on the
value of number.
8. Save the program as randomimage.html.
9. Finally run the program through browser.

30
PROGRAM:
<html>
<head>
<script>
function randomimage()
{
var r=new Array("image1.jpg","image2.jpg","image3.jpg");
var number=Math.floor(Math.random()*r.length);
return document.getElementById("result").src=r[number];
}
</script>
</head>
<body>
<img src="image1.jpg"height="500"width="500"id="result">
<br><br>
<button onclick="setInterval(randomimage,1000)">click</button>
</body>
</html>

31
OUTPUT:

32
RESULT:
Thus the program was executed successfully.
33
EX:NO:08 E-MAIL ADDRESS VALIDATION
DATE:

AIM:
To write a JavaScript program to display a random image.
PROCEDURE:
1. Open the notepad and type the program.
2. The onclick event occurs when the user click button. In this event function validate() is called.
3. In validate() method create a variable text, and get the value.
4. To get a vali email id we use aregular expression /^([A-Za-z0-9\.-])+@([a-z]{5}).9[a-z]{3})$/
5. The test() method.tests for a match in a string. if it finds a match, it returns true, otherwise it returns false.
6. Save the program as emailvalidation.html.
7. Finally run the program through browser.

34
PROGRAM:
<html>
<head>
<script>
function validate()
{
var text=document.getElementById("text1").value;
var regx=/^([A-Za-z0-9\.-])+@([a-z]{5}).([a-z]{3})$/;
if(regx.test(text))
{ alert("VALID");}
else
{
alert("NOT VALID");
}}
</script>
</head>
<body>
<form>
<h1>***valid email address***</h1><br>
<input type="text"id="text1"placeholder="Email"><br><br>
<button onclick="validate()">submit</button>
</form>
</body>
</html>

35
OUTPUT:

36
RESULT:
Thus the program was executed successfully.
37
EX:NO:09
ADD CONTENT OF ANOTHER JSP FILES
DATE:

AIM:
To write a JSP program to add the contents of another JSP file using @ include directive.
PROCEDURE:
1. Open the notepad and type the program.
2. Save the program as main.jsp in c:\programfiles\apache software foundation\tomcat9.0\wed
apps\kalees\main.jsp.
Flooder name=kalees, file name =main.jsp.
3. In main.jsp include the file header.jsp and footer.jsp by using JSP include directive.
4. The JSP include directive is used to include static resource into the current JSP page at translation time.
Example:%@include file=”header.jsp”%.
5. Finally run the program though browser by type localhost:8080/main.jsp.
6. If the tomcat home page does to come then do the following steps.
i. Open the command prompt and type netstat–ano|findstr 8080
ii. End the task which come in command prompt.
7. http://localhost:8080/austin/main.jsp.

38
PROGRAM:
Main.jsp
<html>
<body>
<h1>****** jsp files*****</h1>
<h2>****** this is main jsp file****</h2>
<br><br><br><br>
<%@include file ="header.jsp"%>
<br><br><br><br>
<%@include file ="footer.jsp"%>
</body>
</html>
Header.jsp
<html>
<body>
<h2>*** this is header jsp file*****</h2>
<br><br>
<%out.println ("chess was invented in india");%>
<br><br>
<%out.println ("prard to be an indian");%>
<br><br>
</body>
</html>

Footer.jsp
<html>
<body>
<h2>****** this is footer jsp file****</h2>
<br><br>
<%out.println ("life is all about balance");%>
</body>
</html>
39
OUTPUT:

40
RESULT:
Thus the program was executed successfully.
41
EX:NO:10
CHECK PRIME OR NOT
DATE:

AIM:
To write a JSP program to check whether the given number is prime or not.
PROCEDURE:
1. Open the notepad and type the program.
2. Save the program as prime1.jsp in c:\programfiles\apache software foundation\tomcat9.0\wed
apps\kalees\prime.jsp.

Folder name=kalees, file name =main.jsp.


3. In prime1.jsp using for loop find the given number is prime or not.
4. Print the result using out.println();.
5. Finally run the program through browser and also give the input through browser by type
localhost:8080/kalees/prime1.jsp?id=5.

42
PROGRAM:
<html>
<body>
<h1>*****prime number*****</h1>
<%
int num=Integer.parseInt(request.getParameter("id"));
int flag=0;
for(int i=2;i<num;i++)
{
if(num%i==0)
{
flag=1;
break;
}}
if(flag==0)
{
out.println("this is a prime number");
}
else
{
out.println("this is not prime number");
}
%>
</body></html>

43
Output:

44
RESULT:
Thus the program was executed successfully.

45
EX:NO:11
FORWARD ONE JSP FILE TO ANOTHER

DATE:

AIM:
To write a JSP program to forward one JSP file to another JSP file using forward action.
PROCEDURE:
1. Open the notepad and type the program.
2. Save the program as prime1.jsp in c:\programfiles\apache software foundation\tomcat9.0\wed apps\
3. In forwardpage.jsp we use JSP forward action tag to forward a request to another JSP. Request can be
forwarded with or without parameter.
4. In this program we are passing 2 parameter along with forward and later we are displaying them on the
forwarded page. In order to fetch the parameters on result.jsp page we are using get Parameter method of
request implicit object.
5. Finally run the program though browser by type localhost:800/au/forwardpage.jsp.

46
PROGRAM:
forwardpage.jsp
<html>
<body>
<h1>*****forward one JSP file to another JSP file**</h1>
<% out.println("before jsp forward action");%>
<h2>Middle of the jsp file</h2>
<jsp:forward page="result.jsp">
<jsp:param name="Studentname" value="kaleeswari"/>
<jsp:param name="Department" value="computer science"/>
</jsp:forward>
<% out.println("after JSP forward action");%>
</body></html>

Result.jsp
<html>
<body>
</h1>***** save tree****</h1><br>
<% out.println("plant a tree today plan for a good future");%>
<p>
<% out.println(request.getParameter("Studentname"));%>
<br>
<% out.println(request.getParameter("Department"));%>
</body>
</html>

47
Output:

48
RESULT:
Thus the program was executed successfully.

49
EX:NO:12
WORK WITH PAGE AND FORMS

DATE:

AIM:
To write the Asp.Net program to work with page and forms.

PROCEDURE:

1. FilenewprojectASP.NET Web Applicationok

2. In Solution Explorer right click WebApplication15AddNewitemWebformAdd

3. In source mode of WebForm1 type the hello world message by using Response.Write() method

4. Save the program

5. Finally run the program

50
PROGRAM
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.vb"
Inherits="WebApplication28.WebForm1" %>

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<%

Response.Write("hello world");

%>
</div>
</form>
</body>

</html>
51
OUTPUT:

52
RESULT:
Thus the program was executed successfully.
53
EX.NO:13 REGISTRATION FORM VALIDATION

DATE:

AIM:

Write an ASP.Net program to validate a registration form.

PROCEDURE:

1. FilenewprojectwebASP.NET empty web applicationok

2. Right the web application(WebApplication3)addnew itemweb formadd

3. In Design mode of WebForm1.aspx insert table with 7 rows and 3 columns

4. In first column type the field names shown in picture. AlignJustify Right

5. In second column of each row drag and drop text box from Toolbox except Gender field row

54
6. In second column Gender field row drag and drop Dropdown list from Toolbox. Edit itemsGive
the list data

7. drop Drag and RequiredFieldValidator from Toolbox in third column of each row

55
8. Give the ErrorMessage like “UserName is required” in properties. Likewise give the ErrorMessage
for all the fiels which is shown in below picture

9. Change the color of ErrorMessage by forecolor option in properties

56
10. Connect RequiredFieldValidator with corresponding text box
 Click RequiredFieldValidator and choose ControlToValidate in properties from that
choose the corresponding text box. Do the same for all RequiredFieldValidator

11. Drag and drop CompareValidator from Toolbox and place third column of Retype Password field
row.

57
12. Give the ErrorMessage like “Both password must be same” in properties. Click CompareValidator
and click ControlToValidate in properties from that choose the corresponding text box

13. Click CompareValidator and click ControlToCompare in properties from that choose the
corresponding text box

58
14. Drag and drop RegularExpressionValidator from Toolbox and place third column of Email id field
row. Give the ErrorMessage like “you must enter the valid Email id” in properties.

59
15. Select RegularExpressionValidator and click ValidationExpression in properties from that choose
Internet e-mail address option

16. Drag and drop Submit and Reset Button from Toolbox

60
17. Double click the Submit button and place the following code in Button1_onclick () method
document.write(“Your Registration is successfull”);

18. Run the program

61
OUTPUT:

62
RESULT:
Thus the program was executed successfully.

63
EX.NO:14
READ STUDENT DETAILS FROM XML FILE

DATE:

AIM:

Write an ASP.Net program to read student details from XML file.

PROCEDURE:

1. FilenewprojectConsole Applicationok

2. Right click the ConsoleApplication2 in Solution ExplorerAddNew ItemXML FileAdd

64
3. Give basic details about students in the Xml file named as XMLFile1.xml

4. In Program.cs file the XmlTextReader class provides read-only access to a stream of XML data.

Copy the fullpath of XML file and paste it in xdoc object

5. The method ReadElementString() reads a text-only element.


6. The method Console.WriteLine() writes the specified data to the standard output stream.
7. Save the program
8. Finally run the program

65
PROGRAM:

XMLFile1.xml

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


<studentdetails>

<student>
<name>Bhuvana</name>
<regno>cs101</regno>
<year>III</year>
<dept>B.Sc(cs)</dept>
<phno>1234567890</phno>
<city>Theni</city>
</student>

<student>
<name>Muthu</name>
<regno>cs102</regno>
<year>II</year>
<dept>B.Sc(cs)</dept>
<phno>0908765432</phno>
<city>Madurai</city>
</student>

<student>
<name>Suruthi</name>
<regno>cs103</regno>
<year>III</year>
<dept>B.Sc(cs)</dept>
<phno>2345678910</phno>
<city>Theni</city>
</student>
</studentdetails>
66
Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine("*****STUDENT DETAILS*****");
XmlTextReader xdoc = new XmlTextReader("C:\\Users\\USER\\Documents\\Visual Studio
2010\\Projects\\ConsoleApplication2\\ConsoleApplication2\\XMLFile1.xml");
while (xdoc.Read())
{
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "name")
{
string s1 = xdoc.ReadElementString();
Console.WriteLine("Name = " + s1);
}
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "regno")
{
string s2 = xdoc.ReadElementString();
Console.WriteLine("Regno = " + s2);
}
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "year")
{
string s3 = xdoc.ReadElementString();
Console.WriteLine("Year = " + s3);

67
}
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "dept")
{
string s4 = xdoc.ReadElementString();
Console.WriteLine("Dept = " + s4);
}
if (xdoc.NodeType == XmlNodeType.Element && xdoc.Name == "phno")
{
string s5 = xdoc.ReadElementString();
Console.WriteLine("Phno = " + s5);
}
}
}
}
}

68
OUTPUT:

69
RESULT:
Thus the program was executed successfully.

70
EX.NO:15
DISPLAY VEHICLE DETAILS IN TREE VIEW CONTROL

DATE:

AIM:

Write an ASP.Net program to display vehicle details in tree view control.

PROCEDURE:

1. Filenewproject

2. Delete the selected content

71
3. From toolbox drag and drop the treeview to Default.aspx design view

72
4. From toolbox drag and drop the XmlDataSource to Default.aspx design view

4. Click WebApplication2AddNew Item

73
5. Choose XML File. Click add

6. Type the following coding in XMLFile1.xml

<car_catalog>
<car>
<name>corrolla</name>
<model>2015</model>
<type>sedan</type>
<price>450000</price>
</car>
<car>
<name>civic</name>
<model>2019</model>
<type>sedan</type>
<price>500000</price>
</car>
<car>
<name>passo</name>

74
<model>2021</model>
<type>hatackchb</type>
<price>800000</price>
</car>
<car>
<name>land cruiser</name>
<model>2022</model>
<type>suv</type>
<price>900000</price>
</car>
</car_catalog>

The xml file will be like this

75
7. In Default.aspx design view click XmlDataSourceconfigure Data SourceXMLFile1.xmlOk

8. In Default.aspx design view click treeviewChoose Data SourceXMLDataSource1

76
9. In TreeView DataBindings Editor
Click car_catalogGive TextField value #Name
Click carGive TextField value #Name

10. In TreeView DataBindings Editor


Click nameGive TextField value #Inner Text
Click modelGive TextField value # Inner Text
Click typeGive TextField value # Inner Text
Click priceGive TextField value # Inner Text

11. Run the program

77
OUTPUT:

78
RESULT:
Thus the program was executed successfully.

79
EX.NO:16
AN APPLICATION USING MENU SERVER CONTROL

DATE:

AIM:

Write an application using menu server control.

PROCEDURE:

1. FileNewWebsiteASP.NET Empty Websiteok

2. In Solution Explorer right click WebApplication15AddNewitemMaster PageAdd

80
3. In Design mode of Master Page Drag and Drop Menu from Navigation of tool box

4. Right click the menuEdit Menu Items


In Menu Item Editor give menu names by edit the text property

81
5. Create Web Forms for all menu items. Enable Select master page option for all Web Forms

6. Click the menuEdit Menu ItemsSelect menu item one by one and choose corresponding
NavigateUrl

82
7. Give color for the text by choose style propertyfontcolor

8. The Default.aspx will be like this:

9. Finally run the program

83
OUTPUT:

84
85
RESULT:
Thus the program was executed successfully.

86
EX.NO:17
STUDENT DATABASE USING SQL DATASOURCE CONTROL

DATE:

AIM:

Write an ASP.Net program to create student database using sql data source control.

PROCEDURE:

1. FileNewProjectASP.NET Empty Web Applicationok

2. Right click WebApplication6 in Solution ExplorerAddNew ItemWeb Formadd

3. In Design view of Webform1.aspx drag and drop GridView from Toolbox

4. In Design view of Webform1.aspx drag and drop SqlDataSource from Toolbox

5. Right click WebApplication6 in Solution ExplorerAddNew ItemSQL Server

DatabaseaddYes

87
6. In Server Explorer click TablesAdd New Table

7. Save the table as Table1ok

88
8. To insert rows in Table click Table1Show Table Data

9. Insert row values in the table

89
10. Click SqlDataSourceConfigure Data SourceNew Connection Database1.mdfNextFinish

11. Select GridViewChoose Data SourceSqlDataSource1

12. Finally run the program


90
OUTPUT:

91
RESULT:
Thus the program was executed successfully.

92
EX.NO:18 DISPLAY EMPLOYEE DETAILS USING SITEMAP DATA SOURCE

DATE:

AIM:

Write an ASP.Net program to display employee details using sitemap data source.

PROCEDURE:

1. FileNewProjectASP.NET Empty Web Applicationok


2. In Design view of Webform1.aspx drag and drop TreeView in Navigation from Toolbox
3. Right click WebApplication4 in Solution ExplorerAddNew ItemWeb Formadd
4. Drag and drop SiteMapDataSource in Data from Toolbox

93
5. Right click WebApplication4 in Solution ExplorerAddNew ItemWeb Form (named as
WebForm2)add
6. In design view of WebForm2 insert table to store employee job details

94
7. Right click WebApplication4 in Solution ExplorerAddNew ItemWeb Form (named as
WebForm3)add
8. In design view of WebForm3 insert table to store employee personal details

9. Right click WebApplication4 in Solution ExplorerAddNew ItemSite Mapadd

95
10. In SiteMap xml file type the following code:

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

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

<siteMapNode url="WebForm1.aspx" title="home" description="home page">

<siteMapNode url="WebForm2.aspx" title="job" description="employee job details " />

<siteMapNode url="WebForm3.aspx" title="personal" description="employee personal details" />

</siteMapNode>

</siteMap>

The Web.sitemap xml file will be like this

96
11. Right click tree viewchoose data source

12. Finally run the program

97
OUTPUT:

Click the job to know employee job details

98
Click the personal to know employee personal details

99
RESULT:
Thus the program was executed successfully.

100
EX.NO:19
DISPLAY PERSONAL DATABASE USING XML
DATE: DATA SOURCE

AIM:

Write an ASP.Net program to display personal database using xmldatasource.

PROCEDURE:

1. FileNewProjectASP.NET Empty Web Applicationok


2. Right click WebApplication5 in Solution ExplorerAddNew ItemWeb Formadd
3. In Design view of Webform1.aspx drag and drop Label from Toolbox
4. Select the label and type the text by click the Text field in Properties
5. In Design view of Webform1.aspx drag and drop GridView from Toolbox

101
6. Select GridView click Auto Formatchoose Classicclick ok

7. Right click WebApplication5 in Solution ExplorerAddNew ItemXML Fileadd

8.Type the following coding in XML File


<?xml version="1.0" encoding="utf-8" ?>
<students>
<student Name="kaleeswari" DOB="16.08.2003" Gender="Female" City="Theni" phone="6789087890"/>
<student Name="karthik" DOB="12.04.2002" Gender="Male" City="bodi" phone="9079087891"/>
<student Name="thavam" DOB="19.08.2003" Gender="Female" City="Madurai" phone="9989087895"/>
<student Name="Rajesh" DOB="09.08.2004" Gender="Male" City="Theni" phone="9567087890"/>
</students>

8. In Design view of Webform1.aspx drag and drop XmlDataSource from Toolbox

102
9. Select XmlDataSource click Configure Data SourceBrowse Data filechoose
XMLFile1.xmlclick ok

10. Select GridView Choose Data SourceSelect XMLDataSource1click ok

11. Finally run the program

103
OUTPUT:

104
RESULT:
Thus the program was executed successfully.

105
EX.NO:20
CREATE WEB PAGE FOR DEPATMENT
DATE:

AIM:

Write an ASP.Net program to create web page for department.

PROCEDURE

1. FileNewWebsiteASP.NET Empty Websiteok

2. In Solution Explorer right click WebsiteAddNewitemMaster PageAdd

3. In Design mode of Master Page Drag and Drop Menu from Navigation of tool box

4. Right click the menuEdit Menu Items. In Menu Item Editor give menu names by edit the text
property

106
5. Create Web Forms for all menu items. Enable Select master page option for all Web Forms

6. Click the menuEdit Menu ItemsSelect menu item one by one and choose corresponding
NavigateUrl

7. Finally run the program

107
OUTPUT

108
RESULT:
Thus the program was executed successfully.

109
EX.NO:21
SEND A MAIL
DATE:

AIM:

Write an ASP.Net program to send a mail.

PROCEDURE:

1. FilenewwebsiteASP.NET Empty Web siteok

2. In Solution Explorer right click Website1AddNewitemWebformAdd

3. In design mode of Default2.aspx insert the table with 3 rows and two columns

4. In the first column type name and email

5. In the second column place 2 textboxes named as textbox1 and textbox2 and also place 1button
named as register by using text property

6. Place the label at last

7. Double click the buttton register and write the codings

8. Before run the program open browser and type : www.google.com/settings/security/lesssecureapps

110
9. ON allow less secure apps

10. Finally run the program

111
PROGRAM:

Default2.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "flasome2k22");
smtp.EnableSsl = true;
MailMessage msg = new MailMessage();
msg.Subject = "Hello " + TextBox1.Text + " Thanks for Register";
msg.Body = "Hi, Thanks For Your Registration, We will Provide You The Latest Update. Thanks";
string toaddress = TextBox2.Text;
msg.To.Add(toaddress);
string fromaddress = "<[email protected]>";
msg.From = new MailAddress(fromaddress);
try
{
112
smtp.Send(msg);
Label1.Text = "Your Email Has Been Registered with Us";
TextBox1.Text = "";
TextBox2.Text = "";
}
catch
{
throw;
}
}
}

113
OUTPUT:

After click the register button. The label displays the message

114
Message sent from the given mail id

115
RESULT:
Thus the program was executed successfully.

116

You might also like