Professional Documents
Culture Documents
Nme Notes
Nme Notes
PROGRAMMING IN
WEB TECHNOLOGY LAB
PRACTICAL WORK REPORT
WEB TECHNOLOGY LAB
by
--------------------------------
Under the guidance of
Mrs.M.PAVITHRA.M.E.,B.Ed.,
APRIL - 2024
DEPARTMENT OF CS, IT & BCA
MARY MATHA COLLEGE OF ARTS AND SCIENCE
(Affiliated to Madurai Kamaraj University)
PERIYAKULAMEAST - 625601
Name :
Reg.No. :
SubjectCode : SCSJC6P
This is to certify that the Bonafide record for practical work done in the Mary Matha
College of Arts and Science for the practical in the academic year 2023- 2024 held
on……………………
7 ANIMATE AN OBJECT
8 VALIDATE FORM
1|Page
S.NO DATE PROGRAM PAGE SIGN
NO
ASP.NET PROGRAMS
13 REGISTERATION FORM
20 WEB PAGE
21 SEND AN MAIL
2|Page
JAVASCRIPT & JSP PROGRAMS
3|Page
Ex.No:1
GENERATING FIBONACCI SERIES
Date:
Aim:
To write a JavaScript Program For Generating Fibonacci Series.
Algorithm:
Step1: Start the program..
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To Perfrom The Fibonacci Series.
Step4:Display the result.
Program:
<html>
<head>
<title> fibonacci.html </title>
</head>
<body style="background-color:pink">
<h3 style="text-align:center; color:white"> Program to generate the Fibonacci Series
</h3>
<script type="text/javascript">
var limit = prompt("Enter the limit 'n' to generate the fibonacci series:", " ");
var f1=0;
var f2=1;
document.write("The limit entered to generate the fibonacci series is: ",limit, "<br/>");
document.write("The fibonacci series : ");
document.write("<br>","",f1," ");
document.write("<br>","",f2," ");
var i,f3;
for(i=2; i<limit; i++)
{
f3=f1+f2;
document.write("<br>","",f3," ");
f1=f2;
4|Page
f2=f3;
}
</script>
</body>
</html>
Output:
Result:
5|Page
Ex.No:2
CHECK WHETHER PALINDROME
Date: OR NOT
Aim:
To write a JavaScript Program For Check Whether Palindrome Or Not.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To Check Whether
Palindrome Or Not .
Step4:Display the result.
6|Page
Program:
<html>
<head>
<script>
function Palindrome()
{
var rem, temp, final = 0;
var number = Number(document.getElementById("N").value);
temp = number;
while(number>0)
{
rem = number%10;
number = parseInt(number/10);
final = final*10+rem;
}
if(final==temp)
{
window.alert("The inputed number is Palindrome");
}
else
{
window.alert("The inputted number is not palindrome");
}
}
</script>
</head>
<body>
<br>
<h1>Whether a number is Palindrome or not</h1>
Enter The Number :<input type="text" name="n" id = "N"/>
<hr color="cyan">
<br>
<center><button onClick="Palindrome()">CHECK</button>
</body>
</html>
7|Page
Output:
Result:
8|Page
Ex.No:3
TO VALID AN EMAIL ADDRESS
Date:
Aim:
To write a JavaScript Program For Valid An Email Address.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To Perfrom to Valid an
email address .
Step4:Display the result.
Program:
<html>
<body bgcolor="pink">
<script type="text/javascript">
9|Page
Output:
Result:
10 | P a g e
Ex.No:4
ARITHMETIC OPERATION USING JAVASCRIPT
Date:
Aim:
To write a JavaScript Program For Arithmetic Operation Using Javascript .
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To PerfromArithmetic
Operation Using Javascript.
Step4:Display the result.
Program:
<html>
<head>
<title>math</title>
<script type= "text/javascript ">
<!--
function oper()
{
varch=parseInt(prompt( "Enter your choice 1.Addition 2.Subtraction 3.Multiplication
4.Division "));
switch(ch)
{
case 1:var v1=parseInt(prompt( "Enter the first value "));
var v2=parseInt(prompt( "Enter the second value "));
var v3=v1+v2;
document.writeln( "<br> "+ "Addition: "+v3);
break;
case 2:var v4=parseInt(prompt( "Enter the first value "));
var v5=parseInt(prompt( "Enter the second value "));
var v6=v4-v5;
document.writeln( "<br> "+ "Subtraction: "+v6);
break;
case 3:var v7=parseInt(prompt( "Enter the first value "));
var v8=parseInt(prompt( "Enter the second value "));
var v9=v7*v8;
document.writeln( "<br> "+ "Multiplication: "+v9);
11 | P a g e
break;
case 4:var v10=parseInt(prompt( "Enter the first value "));
var v11=parseInt(prompt( "Enter the second value "));
var v12=v10/v11;
document.writeln( "<br> "+ "Divison: "+v12);
break;
case 5:var v13=parseInt(prompt( "Enter the first value "));
var v14=parseInt(prompt( "Enter the second value "));
var v15=v13%v14;
document.writeln( "<br> "+ "Modulus: "+v15);
break;
default: document.writeln( "Enter choice correctly ");
}
}
</script>
</head>
<body bgcolor="green" onLoad= "oper()"></body>
</html>
12 | P a g e
Output:
Result:
Thus the program was written, executed and verified successfully.
13 | P a g e
Ex.No:5
TO REMOVE ITEMS FROM A DROP DOWN LIST
Date:
Aim:
To write a JavaScript Program For Remove Items From A Drop Down List.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To Remove Items From A
Drop Down List.
Step4:Display the result.
14 | P a g e
Program:
<html>
<head>
</head>
<body>
<form>
<select id="colorSelect">
<option>Red</option>
<option>Green</option>
<option>White</option>
<option>Black</option>
<option>Purple</option>
<option>Blue</option>
</select>
<input type="button" onclick="removecolor()" value="Select and Remove">
</form>
</body>
</html>
15 | P a g e
Output:
Result:
Thus the program was written, executed and verified successfully.
16 | P a g e
Ex.No:6
DISPLAY A RANDOM IMAGE
Date:
Aim:
To write a JavaScript Program For Display A Random Image.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To Display A Random
Image .
Step4:Display the result.
Program:
<html>
<head>
<title> Random Image Generator </title>
</head>
<script>
function getRandomImage() {
//declare an array to store the images
varrandomImage = new Array();
17 | P a g e
</script>
<body>
<center><h2 style="color:green"> Random Image Generator </h2></center>
<h4> Click the button to generate and display random images on the webpage </h4>
<!-- call user-defined getRandomImage function after 2 seconds -->
<button onclick = "setInterval(getRandomImage, 2000)"> Generate Image </button>
<br><br>
<span id="result" align="center"></span>
</body>
</html>
18 | P a g e
Output:
Result:
Thus the program was written, executed and verified successfully.
19 | P a g e
Ex.No:7
ANIMATE AN OBJECT
Date:
Aim:
To write a JavaScript Program For Animate An Object.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To PerfromAnimate An
Object .
Step4:Display the result.
Program:
<html>
<head>
<title>JavaScript Animation</title>
<script type = "text/javascript">
<!--
varimgObj = null;
function init() {
imgObj = document.getElementById('myImage');
imgObj.style.position= 'relative';
imgObj.style.left = '0px';
}
function moveRight() {
imgObj.style.left = parseInt(imgObj.style.left) + 10 + 'px';
}
window.onload = init;
//-->
</script>
</head>
<body>
<form>
<img id = "myImage" src = "/img/a.jpg" height=200 widt=200 />
<p>Click button below to move the image to right</p>
<input type = "button" value = "Click Me" onclick = "moveRight();" />
</form>
</body>
20 | P a g e
</html>
Output:
Result:
21 | P a g e
Ex.No:8
VALIDATE FORM
Date:
Aim:
To write a JavaScript Program For Validate Form.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To PerfromValidate Form.
Step4:Display the result.
Program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript Form validation</title>
<link rel="stylesheet" href="/examples/css/form-style.css">
<script>
// Defining a function to display error message
function printError(elemId, hintMsg) {
document.getElementById(elemId).innerHTML = hintMsg;
}
// Validate name
if(name == "") {
printError("nameErr", "Please enter your name");
} else {
var regex = /^[a-zA-Z\s]+$/;
if(regex.test(name) === false) {
printError("nameErr", "Please enter a valid name");
} else {
printError("nameErr", "");
nameErr = false;
}
}
// Validate gender
if(gender == "") {
printError("genderErr", "Please select your gender");
} else {
printError("genderErr", "");
genderErr = false;
}
// Prevent the form from being submitted if there are any errors
if((nameErr || emailErr || mobileErr || countryErr || genderErr) == true) {
return false;
} else {
// Creating a string from input data for preview
vardataPreview = "You've entered the following details: \n" +
"Full Name: " + name + "\n" +
"Email Address: " + email + "\n" +
"Mobile Number: " + mobile + "\n" +
"Country: " + country + "\n" +
"Gender: " + gender + "\n";
if(hobbies.length)
{
dataPreview += "Hobbies: " + hobbies.join(", ");
}
// Display input data in a dialog box before submitting the form
alert(dataPreview);
docmet.write("Your Form has Successfully Registered");
}
};
</script>
</head>
<body>
<form name="contactForm" onsubmit="return validateForm()"
action="/examples/actions/confirmation.php" method="post">
<h2>Application Form</h2>
<div class="row">
<label>Full Name</label>
<input type="text" name="name"> 24 | P a g e
<div class="error" id="nameErr"></div>
</div>
<div class="row">
<label>Email Address</label>
<input type="text" name="email">
<div class="error" id="emailErr"></div>
</div>
<div class="row">
<label>Mobile Number</label>
<input type="text" name="mobile" maxlength="10">
<div class="error" id="mobileErr"></div>
</div>
<div class="row">
<label>Country</label>
<select name="country">
<option>Select</option>
<option>Australia</option>
<option>India</option>
<option>United States</option>
<option>United Kingdom</option>
</select>
<div class="error" id="countryErr"></div>
</div>
<div class="row">
<label>Gender</label>
<div class="form-inline">
<label><input type="radio" name="gender" value="male"> Male</label>
<label><input type="radio" name="gender" value="female"> Female</label>
</div>
<div class="error" id="genderErr"></div>
</div>
<div class="row">
<label>Hobbies <i>(Optional)</i></label>
<div class="form-inline">
<label><input type="checkbox" name="hobbies[]" value="sports"> Sports</label>
<label><input type="checkbox" name="hobbies[]" value="movies"> Movies</label>
<label><input type="checkbox" name="hobbies[]" value="music"> Music</label>
</div>
</div>
<div class="row">
<input type="submit" value="Submit">
</div>
</form>
</body>
</html> 25 | P a g e
Output:
Result:
Thus the program was written, executed and verified successfully.
26 | P a g e
Ex.No:9
PRIME NUMBER CHECKING
Date:
Aim:
To write a JSP Program to check whether the given number is prime or not.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To PerfromCheck Whether
The Given Number Is Prime Or Not .
Step4:Display the result.
Program:
//prime.html
<%--
Document : index
Created on : 12 Oct, 2012, 7:35:11 PM
Author : nested code team
--%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body><br><br><center>
<form action="primejsp.jsp ">
<h1>Enter the no :: <input type=text name=n ><br><br>
<input type=submit value="Submit"></h1>
</form></center>
</body>
</html>
//primejsp.jsp
27 | P a g e
<%--
Document : primejsp
Created on : 31 Oct, 2012, 11:59:34 AM
Author :NESTED CODE
--%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body><center><h1>The required Result is:: </h1>
<h2>
<%
intn,i,flag=0;
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
}
if(flag==0)
{
out.println("<pre>");
out.println(n+" is a prime no.");
out.println("</pre>");
}
else
{
28 | P a g e
out.println("<pre>");
out.println(n+" is not a prime no.");
out.println("</pre>");
}
%>
</h2></center>
</body>
</html>
Output
Result:
Thus the program was written, executed and verified successfully.
29 | P a g e
Ex.No:10
ADD THE CONTENTS OF ANOTHER JSP FILE
Date: USING @INCLUDE DIRECTIVE
Aim:
Write a JSP to add the contents of another JSP file using @include directive.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding to add the contents
of another JSP file using @include directive .
Step4:Display the result.
Program:
index.jsp
<html>
<head>
<title>Main JSP Page</title>
</head>
<body>
<%@ include file="file1.jsp" %>
Main JSP Page: Content between two include directives.
<%@ include file="file2.jsp" %>
</body>
file1.jsp
<palign="center">
This is my File1.jsp and I will include it in index.jsp using include directive
</p>
file2.jsp
<palign="center">
This is File2.jsp
30 | P a g e
</p>
Output
Result:
Thus the program was written, executed and verified successfully.
31 | P a g e
Ex.No:11
FORWARD ONE JSP FILE TO ANOTHER
Date: JSP FILE USING FORWARD ACTION
Aim:
Write a JSP To forward one JSP file to another JSP file Using forward
Action.
.
Algorithm:
Step1: Start the program.
Step2: Design the from using the html tags.
Step3: Include the Java Script Coding To Forward One
JSP File To Another JSP File Using Forward Action .
Step4:Display the result.
Program:
index.jsp
<html>
<head>
<title>JSP forward action tag example</title>
</head>
<body>
<palign="center">My main JSP page</p>
<jsp:forwardpage="display.jsp"/>
</body>
</html>
display.jsp
<html>
<head>
<title>Display Page</title>
32 | P a g e
</head>
<body>
Hello this is a display.jsp Page
</body>
</html>
Output :
Result:
Thus the program was written, executed and verified successfully.
33 | P a g e
ASP .NET PROGRAMS
34 | P a g e
Ex.No:12
CHANGING TEXT BOX FORE AND BACK
Date: COLOR
AIM:
To write an ASP.NET program to change the background and fore color of the textbox.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Place required controls for the application
5. write the necessary coding in C#
6. Run the application.
FORE CLOR.ASPX :
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs"Inherits=
"change_backcolor_and_forecolor.WebForm1"%>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<divstyle="height: 226px; width: 1498px">
<h2style="color:Green">Changing Backcolor and Forecolor of Textbox</h2>
<asp:Label
ID="Label1"
runat="server"
Text="Enter Your Text"
></asp:Label>
<asp:TextBox
ID="TextBox1"
runat="server"style="z-index: 1; left: 240px; top: 72px; position: absolute"
>
</asp:TextBox>
<br/><br/>
<asp:Button
ID="Button1"
runat="server"
35 | P a g e
ForeColor="Red"
Text="Change the ForeColor"
OnClick="Button1_Click"
Font-Bold="true"
style="z-index: 1; left: 533px; top: 134px; position: absolute"Width="454px"
/>
<asp:Button
ID="Button2"
runat="server"
Font-Bold="true"
ForeColor="Red"
Text="Change TheBackColor "
OnClick="Button2_Click"
style="z-index: 1; left: 72px; top: 134px; position: absolute; right: 1035px; margin-top:
0px"Width="421px"
/>
</div>
</form>
</body>
</html>
FORE COLOR.ASPX.CS :
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
namespacechange_backcolor_and_forecolor
{
publicpartialclassWebForm1 :System.Web.UI.Page
{
protectedvoidPage_Load(object sender, EventArgs e)
{
36 | P a g e
{
TextBox1.BackColor = System.Drawing.Color.Cyan;
}
}
}
OUTPUT :
RESULT:
Thus, the above ASP. NET program has been successfully verified and output is shown.
37 | P a g e
Ex.No:13
REGISTERATION FORM
Date:
AIM:
To write an ASP.NET program to create a registration form.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Place required controls for the application
5. write the necessary coding in C#
6. Run the application.
REGISTERATION.ASPX
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Registration
form.aspx.cs"Inherits="WebApplication14.WebForm1"%>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<styletype="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 278px;
}
.auto-style3 {
width: 278px;
height: 23px;
}
.auto-style4 {
height: 23px;
}
</style>
<title>Registration Form</title>
</head>
<body>
<formid="form1"runat="server">
38 | P a g e
<div>
<tableclass="auto-style1">
<tr>
<td>
<asp:LabelID="Label1"runat="server"Text="User Name"></asp:Label>
</td>
<td>
<asp:TextBoxID="username"runat="server"required="true"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:LabelID="Label6"runat="server"Text="Email ID"></asp:Label>
</td>
<td>
<asp:TextBoxID="EmailID"runat="server"TextMode="Email"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:LabelID="Label2"runat="server"Text="Password"></asp:Label></td>
<td>
<asp:TextBoxID="TextBox2"runat="server"TextMode="Password"></asp:TextBox></t
d>
</tr>
<tr>
<td>
<asp:LabelID="Label3"runat="server"Text="Confirm Password"></asp:Label></td>
<td>
<asp:TextBoxID="TextBox3"runat="server"TextMode="Password"></asp:TextBox></t
d>
</tr>
<tr>
<td>
<asp:LabelID="Label4"runat="server"Text="Gender"></asp:Label></td>
<td>
<asp:RadioButtonID="RadioButton1"runat="server"GroupName="gender"Text="Male"/
>
<asp:RadioButtonID="RadioButton2"runat="server"GroupName="gender"Text="Femal
e"/></td>
</tr>
<tr>
<td>
<asp:LabelID="Label5"runat="server"Text="Select Course"></asp:Label>s</td>
<td>
<asp:CheckBoxID="CheckBox1"runat="server"Text="DOTNET"/>
<asp:CheckBoxID="CheckBox2"runat="server"Text="PYTHON"/>
39 | P a g e
<asp:CheckBoxID="CheckBox3"runat="server"Text="PHP"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<br/>
<asp:ButtonID="Button1"runat="server"Text="Register"CssClass="btnbtn-
primary"OnClick="Button1_Click"/>
</td>
</tr>
</table>
<asp:LabelID="message"runat="server"Font-
Size="Medium"ForeColor="Red"></asp:Label>
</div>
</form>
<tableclass="auto-style1">
<tr>
<tdclass="auto-
style2"><asp:LabelID="ShowUserNameLabel"runat="server"></asp:Label></td>
<td>
<asp:LabelID="ShowUserName"runat="server"></asp:Label></td>
</tr>
<tr>
<tdclass="auto-
style2"><asp:LabelID="ShowEmailIDLabel"runat="server"></asp:Label></td>
<td>
<asp:LabelID="ShowEmail"runat="server"></asp:Label></td>
</tr>
<tr>
<tdclass="auto-
style3"><asp:LabelID="ShowGenderLabel"runat="server"></asp:Label></td>
<tdclass="auto-style4">
<asp:LabelID="ShowGender"runat="server"></asp:Label></td>
</tr>
<tr>
<tdclass="auto-
style2"><asp:LabelID="ShowCourseLabel"runat="server"></asp:Label></td>
<td>
<asp:LabelID="ShowCourses"runat="server"></asp:Label></td>
</tr>
</table>
</div>
</form>
40 | P a g e
</body>
</html>
REGISTERATION.ASPX.CS
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
namespace WebApplication14
{
publicpartialclassWebForm1 :System.Web.UI.Page
{
protectedvoidPage_Load(object sender, EventArgs e)
{
41 | P a g e
ShowEmailIDLabel.Text = "Email ID";
ShowGenderLabel.Text = "Gender";
ShowCourseLabel.Text = "Courses";
username.Text = "";
EmailID.Text = "";
RadioButton1.Checked = false;
RadioButton2.Checked = false;
CheckBox1.Checked = false;
CheckBox2.Checked = false;
CheckBox3.Checked = false;
}
}
}
OUTPUT :
42 | P a g e
RESULT:
Thus the above ASP. NET program has been successfully verified and output is shown.
43 | P a g e
Ex.No:14
DISPLAYING STUDENT DETAILS FROM
Date: XML FILE
AIM:
To write an ASP.NET program to display the student details from xml file.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Place required controls for the application
5.Iinclude the xml file
Solution explorer right click -> add -> new item -> xml file.
6.write the necessary coding in C#
7. Run the application.
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Data;
namespace WebApplication11
{
publicpartialclassWebForm1 :System.Web.UI.Page
{
protectedvoidPage_Load(object sender, EventArgs e)
{
if(!this.IsPostBack)
{
this.BindGrid();
}
privatevoidBindGrid()
{
using(DataSet ds = newDataSet())
{
44 | P a g e
ds.ReadXml(Server.MapPath ("~/student.xml"));
GridView1.DataSource=ds;
GridView1.DataBind();
}
}
}
}
Webfrom1.aspx
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<divstyle="height:276px">
<asp:GridViewID="GridView1"runat="server"BackColor="Aqua">
<Columns>
<asp:BoundFieldDataField="sname"HeaderText="Student name"ItemStyle-Width="80"/>
<asp:BoundFieldDataField="regno"HeaderText="Register No"ItemStyle-Width="90"/>
<asp:BoundFieldDataField="m1"HeaderText="Mark1"ItemStyle-Width="80"/>
<asp:BoundFieldDataField="m2"HeaderText="Mark2"ItemStyle-Width="90"/>
<asp:BoundFieldDataField="m3"HeaderText="Mark3"ItemStyle-Width="80"/>
<asp:BoundFieldDataField="m4"HeaderText="Mark4"ItemStyle-Width="90"/>
<asp:BoundFieldDataField="m5"HeaderText="Mark5"ItemStyle-Width="80"/>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
45 | P a g e
Student.xml
<?xmlversion="1.0"encoding="utf-8" ?>
<studentdetail>
<student>
<sname>Anu</sname>
<regno>101</regno>
<m1>67</m1>
<m2>89</m2>
<m3>78</m3>
<m4>80</m4>
<m5>90</m5>
</student>
<student>
<sname>salo</sname>
<regno>103</regno>
<m1>90</m1>
<m2>85</m2>
<m3>70</m3>
<m4>56</m4>
<m5>78</m5>
</student>
<student>
<sname>nivi</sname>
<regno>135</regno>
<m1>68</m1>
<m2>49</m2>
<m3>90</m3>
<m4>58</m4>
<m5>70</m5>
</student>
</studentdetail>
46 | P a g e
OUTPUT:
RESULT:
Thus the above ASP. NET program has been successfully verified and output is shown.
47 | P a g e
Ex.No:15
DISPLAYING VEHICELS DETAILS USING
Date: TREE
VIEW CONTROL
AIM:
To write an ASP.NET program to display the vehicle details using Tree view control.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Place required controls for the application
5.Iinclude the xml file
Solution explorer right click -> add -> new item -> xml file.
6.write the necessary coding in C#
7. Run the application.
VEHICLE.ASPX
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs"Inherits=
"WebApplication6.WebForm1"%>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<divstyle="height: 402px">
<asp:LabelID="Label1"runat="server"BackColor="Aqua"
style="z-index: 1; left: 539px; top: 31px; position: absolute; width: 205px"
Text="Vehicle Details"></asp:Label>
<asp:TreeViewID="TreeView1"runat="server"
style="z-index: 1; left: 221px; top: 109px; position: absolute; height: 160px; width: 116px"
DataSourceID="XmlDataSource1">
</asp:TreeView>
<asp:XmlDataSourceID="XmlDataSource1"runat="server"DataFile="~/vehicle.xml"XPath="/ve
hicles"></asp:XmlDataSource>
48 | P a g e
</div>
</form>
</body>
</html>
VEHICLE.XML
<?xmlversion="1.0"encoding="utf-8" ?>
<vehicles>
<cars>
<Alto/>
<BMW/>
<Hyundai/>
<Audi/>
</cars>
<bikes>
<TVS/>
<Yamaha/>
<RoyalEnfield/>
<Honda/>
</bikes>
</vehicles>
49 | P a g e
OUTPUT:
RESULT:
Thus, the above ASP. NET program has been successfully verified and output is shown.
50 | P a g e
Ex.No:16
MENU SERVER CONTROL
Date:
AIM:
To write an ASP.NET program using menu server control.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Place required controls for the application
5. write the necessary coding in C#
6. Run the application.
DYNAMIC MENU.ASPX
color: #444;
} <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynamicMenu.aspx.cs
" Inherits="DynamicMenu" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Dynamic Menu Control Article for C# Corner by Upendra Pratap Shahi</title>
<style type="text/css">
body {
background-color: mediumaquamarine;
font-family: Arial;
font-size: 10pt;
.ParentMenu, .ParentMenu:hover {
width: 100px;
background-color: #fff;
color: #333;
text-align: center;
height: 30px;
line-height: 30px;
margin-right: 5px;
}
.ParentMenu:hover {
background-color: #ccc;
}
.ChildMenu, .ChildMenu:hover {
width: 110px;
51 | P a g e
background-color: #fff;
color: #333;
text-align: center;
height: 30px;
line-height: 30px;
margin-top: 5px;
}
.ChildMenu:hover {
background-color: #ccc;
}
.selected, .selected:hover {
background-color: #A6A6A6 !important;
color: #fff;
}
.level2 {
background-color: #fff;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
<LevelMenuItemStyles>
<asp:MenuItemStyle CssClass="ParentMenu" />
<asp:MenuItemStyle CssClass="ChildMenu" />
<asp:MenuItemStyle CssClass="ChildMenu" />
</LevelMenuItemStyles>
<StaticSelectedStyle CssClass="selected" />
</asp:Menu>
</div>
</form>
</body>
</html>
52 | P a g e
Adding the following namespaces in the namespace section of your code behind page.
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
Now your page looks as in the following.
DYNAMIC MENU.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.IO;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
53 | P a g e
DataTable dt = this.BindMenuData(0);
DynamicMenuControlPopulation(dt, 0, null);
}
}
/// <summary>
/// This function retur a datatable according to parent menu id passed by user
/// </summary>
/// <param name="parentmenuId">parent menu ID</param>
/// <returns>data table</returns>
protected DataTable BindMenuData(int parentmenuId)
{
//declaration of variable used
DataSet ds = new DataSet();
DataTable dt;
DataRow dr;
DataColumn menu;
DataColumn pMenu;
DataColumn title;
DataColumn description;
DataColumn URL;
//create an object of datatable
dt=new DataTable();
54 | P a g e
//2nd row of data table
dr = dt.NewRow();
dr["MenuId"] = 2;
dr["ParentId"] = 0;
dr["Title"] = "Customer Service";
dr["Description"] = "Customer Service";
dr["URL"] = "~/Customer.aspx";
dt.Rows.Add(dr);
55 | P a g e
//7th row of data table
dr = dt.NewRow();
dr["MenuId"] = 7;
dr["ParentId"] = 2;
dr["Title"] = "Outsourcing";
dr["Description"] = "Outsourcing page";
dr["URL"] = "~/Outsource.aspx";
dt.Rows.Add(dr);
ds.Tables.Add(dt);
var dv = ds.Tables[0].DefaultView;
dv.RowFilter = "ParentId='" + parentmenuId + "'";
DataSet ds1 = new DataSet();
var newdt = dv.ToTable();
return newdt;
}
/// <summary>
/// This is a recursive function to fetchout the data to create a menu from data table
/// </summary>
/// <param name="dt">datatable</param>
/// <param name="parentMenuId">parent menu Id of integer type</param>
/// <param name="parentMenuItem"> Menu Item control</param>
protected void DynamicMenuControlPopulation(DataTable dt, int parentMenuId, MenuItem
parentMenuItem)
{
string currentPage = Path.GetFileName(Request.Url.AbsolutePath);
foreach (DataRow row in dt.Rows)
56 | P a g e
{
MenuItem menuItem = new MenuItem
{
Value = row["MenuId"].ToString(),
Text = row["Title"].ToString(),
NavigateUrl = row["URL"].ToString(),
Selected = row["URL"].ToString().EndsWith(currentPage, StringComparison.Current
CultureIgnoreCase)
};
if (parentMenuId == 0)
{
Menu1.Items.Add(menuItem);
DataTable dtChild = this.BindMenuData(int.Parse(menuItem.Value));
DynamicMenuControlPopulation(dtChild, int.Parse(menuItem.Value), menuItem);
}
else
{
parentMenuItem.ChildItems.Add(menuItem);
DataTable dtChild = this.BindMenuData(int.Parse(menuItem.Value));
DynamicMenuControlPopulation(dtChild, int.Parse(menuItem.Value), menuItem);
}
}
}
}
57 | P a g e
OUTPUT:
58 | P a g e
RESULT:
Thus, the above ASP. NET program has been successfully verified and output is shown.
59 | P a g e
Ex.No:17
DISPLAYING STUDENT DETAILS FROM
Date: DATABASE
AIM:
To write an ASP.NET program to display the student details using SqlDataSource and
Grid view.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Place required controls for the application
5.Iinclude the xml file
Solution explorer right click -> add -> new item -> xml file.
6.write the necessary coding in C#
7. Run the application.
STUDENT.ASPX.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
namespace DatabaseConnectivity
{
public partial class loginpage System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[
"RegiConnectionString"].ConnectionString);
conn.Open();
string checkuser = "select count(*) from RegisterDataBase where StudentName='"+Te
xtBox1.Text+"'";
60 | P a g e
SqlCommand cmd = new SqlCommand(checkuser, conn);
int temp = Convert.ToInt32(cmd.ExecuteScalar().ToString());
if (temp == 1)
{
Response.Write("Student Already Exist");
}
conn.Close();
}
conn.Close();
}
catch (Exception ex)
{
Response.Write("error" + ex.ToString());
}
}
}
}
61 | P a g e
STUDENT.ASPX
<!DOCTYPE html>
<html xmlns="http//www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="stylepage.css" type="text/css" rel="stylesheet" />
<style type="text/css">
.auto-style1 {
width 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="title">
<h1>REGISTER PAGE</h1>
</div>
<div id ="teble"></div>
<table class="auto-style1">
<tr>
<td>
<aspLabel ID="Label1" runat="server" Text="StudentName"></aspLabel></td>
<td>
<aspTextBox ID="TextBox1" runat="server"></aspTextBox></td>
</tr>
<tr>
<td>
<aspLabel ID="Label2" runat="server" Text="Password"></aspLabel></td>
<td>
<aspTextBox ID="TextBox2" runat="server"></aspTextBox></td>
</tr>
<tr>
<td>
<aspLabel ID="Label3" runat="server" Text="EmailId"></aspLabel></td>
<td>
<aspTextBox ID="TextBox3" runat="server"></aspTextBox></td>
</tr>
<tr>
<td>
62 | P a g e
<aspLabel ID="Label4" runat="server" Text="Department"></aspLabel></td>
<td>
<aspTextBox ID="TextBox4" runat="server"></aspTextBox></td>
</tr>
<tr>
<td>
<aspLabel ID="Label5" runat="server" Text="College"></aspLabel></td>
<td>
<aspTextBox ID="TextBox5" runat="server"></aspTextBox></td>
</tr>
</table>
<div id="button">
<aspButton ID="Button1" runat="server" Text="submit" OnClick="Button1_Click" BackC
olor="Yellow" />
</div>
<div id="sim"></div>
<aspSqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ Connect
ionStringsRegiConnectionString %>" SelectCommand="SELECT * FROM [RegisterDataBase]"
></aspSqlDataSource>
<div id="grid">
<aspGridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="Tr
ue" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" ForeCol
or="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<aspBoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
<aspBoundField DataField="StudentName" HeaderText="StudentName" SortExpre
ssion="StudentName" />
<aspBoundField DataField="Passwords" HeaderText="Passwords" SortExpression=
"Passwords" />
<aspBoundField DataField="EmailId" HeaderText="EmailId" SortExpression="Em
ailId" />
<aspBoundField DataField="Department" HeaderText="Department" SortExpressio
n="Department" />
<aspBoundField DataField="College" HeaderText="College" SortExpression="Coll
ege" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" -Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" -Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" -Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
63 | P a g e
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</aspGridView>
</div>
<div id="last">
<h3>Developed by
Muthuramalingam Duraipandi</h3>
</div>
</form>
</body>
</html>
OUTPUT:
RESULT:
Thus, the above ASP. NET program has been successfully verified and output is shown.
64 | P a g e
Ex.No:18
SITEMAP DATA SOURCE
Date:
AIM:
To write an ASP.NET program using sitemap data control.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Solution explorer right click -> add -> new item ->web.sitemap
4. Place required controls for the application
5. write the necessary coding in C#
6. Run the application.
TUTORIAL.sitemap
<?xmlversion="1.0"encoding="utf-8" ?>
<siteMapxmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<siteMapNodeurl=""title="My Favourate"description="Favourate">
<siteMapNodeurl="www.google.com"title="c-sharpcorner"description="microsoft
technology world" />
<siteMapNodeurl="www.vbdotnetheaven.com"title="vbdotnetheaven.com"description="
vb.net world" />
<siteMapNodeurl="www.longhorncorner.com"title="longhorncorner.com"description="
XAML,WPF world" />
</siteMapNode>
<siteMapNodeurl=""title="Movies"description="my fav movies">
<siteMapNodeurl=""title="Gladiator"description="Gladiator"></siteMapNode>
65 | P a g e
</siteMapNode>
</siteMapNode>
</siteMapNode>
</siteMap>
<?xmlversion="1.0"encoding="utf-8" ?>
<siteMapxmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<siteMapNodeurl=""title="My Favourate"description="Favourate">
<siteMapNodeurl="www.google.com"title="c-sharpcorner"description="microsoft
technology world" />
<siteMapNodeurl="www.vbdotnetheaven.com"title="vbdotnetheaven.com"description="
vb.net world" />
<siteMapNodeurl="www.longhorncorner.com"title="longhorncorner.com"description="
XAML,WPF world" />
</siteMapNode>
<siteMapNodeurl=""title="Gladiator"description="Gladiator"></siteMapNode>
</siteMapNode>
66 | P a g e
<siteMapNodeurl=""title="John Cena"description="john cena the marine
guy"></siteMapNode>
</siteMapNode>
</siteMapNode>
</siteMap>
Web.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs"In
herits="sitemap.WebForm1"%>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
.style1
{
text-align: center;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<divclass="style1"style="height: 578px">
<strongstyle="text-align: center">
<br/>
SITEMAPDATASOURCE
EXAMPLE<asp:SiteMapDataSourceID="SiteMapDataSource1"
runat="server"/>
<asp:TreeViewID="TreeView1"runat="server"DataSourceID="SiteMapDataSource1"
ImageSet="WindowsHelp"
style="z-index: 1; left: 462px; top: 210px; position: absolute; height: 253px; width:
255px">
<HoverNodeStyleFont-Underline="True"ForeColor="#6666AA"/>
<NodeStyleFont-Names="Tahoma"Font-Size="8pt"ForeColor="Black"
67 | P a g e
HorizontalPadding="5px"NodeSpacing="0px"VerticalPadding="1px"/>
<ParentNodeStyleFont-Bold="False"/>
<SelectedNodeStyleBackColor="#B5B5B5"Font-Underline="False"
HorizontalPadding="0px"VerticalPadding="0px"/>
</asp:TreeView>
</strong>
</div>
</form>
</body>
</html>
68 | P a g e
Output:
RESULT:
Thus, the above ASP. NET program has been successfully verified and output is shown.
69 | P a g e
Ex.No:19
EMPLOYEE DETAILS USING XML DATA
Date: SOURCE
AIM:
To write an ASP.NET program to display the employee details from using Grid view.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Place required controls for the application
5.Iinclude the xml file
Solution explorer right click -> add -> new item -> xml file.
6.write the necessary coding in C#
7. Run the application.
EMPLOYEE.XML
<Employees>
<EmployeeId ="1"City ="Chennai">
<EmployeeName>Arun</EmployeeName>
<Country>India</Country>
</Employee>
<EmployeeId ="2"City ="Madurai">
<EmployeeName>Bhavani</EmployeeName>
<Country>India</Country>
</Employee>
<EmployeeId ="3"City ="Coimbatore">
<EmployeeName>Kannan</EmployeeName>
<Country>India</Country>
</Employee>
<EmployeeId ="4"City ="London">
<EmployeeName>Jhon</EmployeeName>
<Country>UK</Country>
</Employee>
<EmployeeId ="5"City = "Newyork">
<EmployeeName>Stephen</EmployeeName>
<Country>USA</Country>
</Employee>
<EmployeeId ="6"City ="Chennai">
<EmployeeName>David</EmployeeName>
<Country>India</Country>
</Employee>
<EmployeeId ="7"City ="London">
<EmployeeName>Robert King</EmployeeName>
70 | P a g e
<Country>UK</Country>
</Employee>
<EmployeeId ="8"City ="Seattle">
<EmployeeName>Laura Callahan</EmployeeName>
<Country>USA</Country>
</Employee>
<EmployeeId ="9"City ="London">
<EmployeeName>Anne Dodsworth</EmployeeName>
<Country>UK</Country>
</Employee>
</Employees>
EMPLOYEE.ASPX
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs"Inherits=
"Employee_details.WebForm1"%>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:DropDownListID="ddlCities"runat="server"OnSelectedIndexChanged="CityChanged"
AutoPostBack="true"style="z-index: 1; left: 401px; top: 12px; position: absolute">
<asp:ListItemText="All"Value=""/>
<asp:ListItemText="Madurai"Value="Seattle"/>
<asp:ListItemText="Chennai"Value="Tacoma"/>
<asp:ListItemText="Coimbatore"Value="Kirkland"/>
<asp:ListItemText="America"Value="Redmond"/>
<asp:ListItemText="London"Value="London"/>
</asp:DropDownList>
Country:
<asp:DropDownListID="ddlCountries"runat="server"OnSelectedIndexChanged="CountryChan
ged"
AutoPostBack="true"
style="z-index: 1; left: 96px; top: 15px; position: absolute; width: 98px; margin-top: 0px">
<asp:ListItemText="All"Value=""/>
<asp:ListItemText="India"Value="India"/>
<asp:ListItemText="USA"Value="USA"/>
<asp:ListItemText="UK"Value="UK"/>
71 | P a g e
</asp:DropDownList>
City:
<hr/>
<asp:XmlDataSourceID="XmlDataSource1"runat="server"DataFile="~/employee.xml">
</asp:XmlDataSource>
<asp:GridViewID="GridView1"runat="server"XPath="/Employees/Employee"DataSourceID="
XmlDataSource1"
AutoGenerateColumns="False"HeaderStyle-BackColor="#3AC0F2"
HeaderStyle-ForeColor="White"
style="z-index: 1; left: 165px; top: 132px; position: absolute; height: 180px; width: 437px">
<Columns>
<asp:TemplateFieldHeaderText="Id"HeaderStyle-Width="50">
<ItemTemplate>
<%# XPath("@Id") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="Name"HeaderStyle-Width="100">
<ItemTemplate>
<%# XPath("EmployeeName") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="City"HeaderStyle-Width="100">
<ItemTemplate>
<%# XPath("@City") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="Country"HeaderStyle-Width="100">
<ItemTemplate>
<%# XPath("Country") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
EMPLOYEE.ASP.CS
using System;
usingSystem.Collections.Generic;
72 | P a g e
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
namespaceEmployee_details
{
publicpartialclassWebForm1 :System.Web.UI.Page
{
protectedvoidPage_Load(object sender, EventArgs e)
{
}
}
}
73 | P a g e
OUTPUT:
74 | P a g e
RESULT:
Thus, the above ASP. NET program has been successfully verified and output is shown.
75 | P a g e
Ex.No:20
SEND AN MAIL
Date:
AIM:
To write an ASP.NET program send a mail.
ALGORITHM:
1. Open Microsoft Visual Studio 2010
2. Click new project -> Asp.net web application with C#
3. Solution explorer right click -> add -> new item -> webform with C#
4. Solution explorer right click -> add -> new item ->web.sitemap
4. Place required controls for the application
5. write the necessary coding in C#
6. Run the application.
Code in SignUp.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<br />
<table width="50%">
<tr>
<td align="center" style="background-color:yellow">
<span style="font-size:25px;"> Welcome To C# Corner </span>
<br />
<br />
</td>
</tr>
<tr align="center">
<td>
<br />
76 | P a g e
<br />
Dear [newusername]
<br />
<br />
Thank you for registering with us!
<br />
<a href="http://www.c-sharpcorner.com">
Click here to Login
</a>
Regards,
<br />
<br />
</td>
</tr>
<tr>
<td align="center" style="background-color:yellow">
<br />
<br />
<span style="font-size:15px;text-
decoration:underline"> Share your knowledge </span>
<br />
<span style="font-
size:20px;"> <i>If you have knowledge, let others light their candles in it -
Margaret Fuller </span>
<br />
<br />
</td>
</tr>
</tr>
</table>
</body> </html>
Code in Web.Config file
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="smtp" value="smtp.gmail.com"/>
<add key="portnumber" value="587"/>
<add key="username" value="xyz@gmail.com"/>
<add key="password" value="abc@123"/>
77 | P a g e
<add key="IsSSL" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
</system.web>
</configuration>
Code in Signup.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Signup.aspx.cs" Inherit
s="Signup" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
height: 30px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>New User (Signup)</h3>
<table>
<tr>
<td>User Name<br />
(Email ID)
</td>
<td>
<asp:TextBox ID="txtUserName" runat="server" Width="200px"></asp:
TextBox>
</td>
</tr>
<tr>
<td>
<br />
Password
</td>
<td>
<br />
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"
78 | P a g e
Width="200px"> </asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" class="auto-style1">
<asp:Button ID="btnSubmit" runat="server" Text="Register (Signup)" On
Click="btnSubmit_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
//System.Net
using System.Net;
using System.Configuration;
using System.IO;
79 | P a g e
string emailSenderHost = ConfigurationManager.AppSettings["smtpserver"].ToStri
ng();
int emailSenderPort = Convert.ToInt16(ConfigurationManager.AppSettings["portnu
mber"]);
Boolean emailIsSSL = Convert.ToBoolean(ConfigurationManager.AppSettings["IsS
SL"]);
//Set To Email ID
_mailmsg.To.Add(txtUserName.Text.ToString());
//Set Subject
_mailmsg.Subject = subject;
80 | P a g e
//Set PORT number of SMTP
_smtp.Port = emailSenderPort;
}
}
OUTPUT:
81 | P a g e
RESULT:
Thus, the above ASP. NET program has been successfully verified and output is shown.
82 | P a g e