Jawaharlal Nehru Engineering College: Laboratory Manual
Jawaharlal Nehru Engineering College: Laboratory Manual
Laboratory Manual
MTL-II (ASP.NET)
For
As you may be aware that MGM has already been awarded with ISO 9000
certification and it is our endure to technically equip our students taking the
advantage of the procedural aspects of ISO 9000 Certification.
Faculty members are also advised that covering these aspects in initial stage
itself, will greatly relived them in future as much of the load will be taken care
by the enthusiasm energies of the students once they are conceptually clear.
Prof. S.D.DESHMUKH
Principal
LABORATORY MANUAL CONTENTS
This manual is intended for the students S.Y (M.C.A) engineering for the
subject of MTL-II (Microsoft Technology Lab). Subject name itself is expecting
what are the advance controls and services that might be used to develop web
applications using Microsoft technology i.e. ASP.NET with code behind
language VB.NET.
In the subject of this manual typically contains practical/Lab Sessions we
have dealt with ASP.NET.
ASP.NET is the next generation ASP, but it's not an upgraded version of ASP.
ASP.NET is an entirely new technology for server-side scripting. It was written
from the ground up and is not backward compatible with classic ASP.
Students are advised to thoroughly go through this manual rather than only
topics mentioned are the key to understanding and conceptual visualization of
theoretical aspects covered in the books.
Lect. J. D. Harne
SUBJECT INDEX:
2. Read carefully the power ratings of the equipment before it is switched on whether ratings 230
V/50
Hz or 115V/60 Hz. For Indian equipments, the power ratings are normally 230V/50Hz. If you
have equipment with 115/60 Hz ratings, do not insert power plug, as our normal supply is
230V/50 Hz, which will damage the equipment.
1. Submission related to whatever lab work has been completed should be done during the next lab
session. The immediate arrangements for printouts related to submission on the day of practical
assignments.
2. Students should be taught for taking the printouts under the observation of lab teacher.
3. The promptness of submission should be encouraged by way of marking and evaluation patterns
that will benefit the sincere students.
WARMUP EXCERCISES:
Validation controls.
Rich controls.
What is SOAP,WSDL,UDDI,DISCO.
[Purpose this exercise is to introduce Client side scripting. Differentiate between client side
scripting and server side scripting. Steps:
1. Write a program in either NOTEPAD or VISUAL STUDIO.NET environment.
2. If VISUAL STUDIO .NET environment then
(i) Right click on Solution Explorer and Select Add New Item.
(ii) Select HTMLPage.htm.
(iii) Write the code (only use HTML Controls from Toolbox).
(iv) Select HTML page in Solution Explorer =>Right click=>Select View in Browser
to execute.
OR
Press F5 button for execution.
3. If NOTEPAD then
(i) Save the file with extension .HTML.
(ii) Click the HTML file for execution.
<HTML>
<HEAD>
<TITLE> Greetings from the web</TITLE>
<script language="javascript" type="text/javascript">
function CheckLogin() {
[Purpose of this exercise is to introduce ASP.NET page life cycle. You can use Visual Studio .NET
environment to type the program. Execution of program in two ways.
1. Press F5 button OR
2. Right click on ASP.NET page (for e.g.: Default.aspx) and Select “View Browser” option and
select any browser for execution.
[Purpose of this exercise is to introduce ASP.NET State management techniques. You can use
Visual Studio .NET environment to type the program. Execution of program in two ways.
1. Press F5 button OR
2. Right click on ASP.NET page (for eg: Default.aspx) and Select “View Browser” option and
select any browser for execution.
Steps:
1. Start a new web site with two web forms. Let Default.aspx and Success.aspx are two web
forms.
2. Design Default.aspx page with fields Employee name, address, contact no, email id and
a submit button.
3. After filling all information, it should be displayed on Success.aspx page using Query String
or Session state management technique.
4. Code using Query String as shown below:
( Default.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
(Success.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Success.aspx.vb"
Inherits="Succcess" %>
[Purpose of this exercise is to use advance web controls. You can use Visual Studio .NET
environment to type the program. Execution of program in two ways.
1. Press F5 button OR
2. Right click on ASP.NET page (for eg: Default.aspx) and Select “View Browser” option and
select any browser for execution.
Steps:
1. Start a new web site with two web forms. Let Default.aspx and Default2.aspx are two
web forms.
2. Take Hyperlink, Linkbutton and Fileupload controls from toolbox.
3. Follow the code:
( Default.aspx)
( Default.aspx.vb)
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles LinkButton1.Click
Label1.Text = "PostBack operation performed on clicking link button"
End Sub
[Purpose of this exercise is to use Rich control i.e. AD ROTATOR Control. You can use Visual
Studio .NET environment to type the program. Execution of program in two ways.
1. Press F5 button OR
2. Right click on ASP.NET page (for e.g.: Default.aspx) and Select “View Browser” option and
select any browser for execution.
3. Refresh the page to see the different images.
Steps:
1. Start a new web site with web forms Default.aspx and Add XMLFile.xml file by right
clicking on Solution Explorer and Select Add New Item and Select XMLFile.xml.
2. Add Ad rotator control in Default.aspx page.
3. Add some images with extension .JPG or .JPEG in application folder.
3. Write the code in Default.aspx and XMLFile.xml as shown below:
( Default.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Adrorator control</title>
</head>
<body>
<form id="form1" runat="server">
<asp:AdRotator ID="AdRotator1" AdvertisementFile ="~/XMLFile.xml" runat="server" Target
="_blank " />
</form>
</body>
</html>
(XMLFile.xml)
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>f2f53cf6.jpg</ImageUrl>
<NavigateUrl>www.gmail.com</NavigateUrl>
<Impressions>2</Impressions>
</Ad>
<Ad>
<ImageUrl>3-idiots-13h.jpg</ImageUrl>
<NavigateUrl>www.yahoo.com</NavigateUrl>
<Impressions>2</Impressions>
</Ad>
</Advertisements>
6. Lab Exercises:
[Purpose of this exercise is to use Validation controls .You can use Visual Studio .NET
environment to type the program. Execution of program in two ways.
1. Press F5 button OR
2. Right click on ASP.NET page (for e.g.: Default.aspx) and Select “View Browser” option and
select any browser for execution.
1. Design a Registration form Default.aspx page with fields Username, choose password,
confirm password, age, email id, city and a submit button.
2. Use:
a) RequiredFieldValidator - for Username, Choose password, Age, Email Id fields.
b) CompareValidator - for Confirm password field.
c) RangeValidator - for Age field.
d) RegularExpressionValidator - for Email field.
e) CustomValidator - for City field.
3. Set the properties for:
a) RequiredFieldValidator - ControlToValidate, ErrorMessage.
b) CompareValidator - ControlToCompare, ControlToValidate, ErrorMessage.
c)RangeValidator - ControlToValidate, ErrorMessage, MaximumValue, MinimumValue,
Type.
d) RegularExpressionValidator - ControlToValidate, ErrorMessage ,ValidationExpression.
e) CustomValidator - ControlToValidate, ErrorMessage, ClientValidationFunction.
4. Write a Client side script to use CustomValidator control (either JavaScript or VBScript).
5. Display message “Successfully Submitted” after Clicking Submit button i.e after successful
validation of registration page.
( Default.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
</script>
</head>
<body onload="return window_onload()">
<form id="form1" runat="server">
<table>
<tr>
<td>
UserName :
</td>
<td>
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtUserName" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Choose Password :
</td>
<td>
<asp:TextBox ID="txtChoosePwd" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtChoosePwd" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Confirm Password :
</td>
<td>
<asp:TextBox ID="txtConfirmPwd" runat="server"></asp:TextBox>
</td>
<td>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtChoosePwd" ControlToValidate="txtConfirmPwd"
ErrorMessage="Password Mismatch"></asp:CompareValidator>
</td>
</tr>
<tr>
<td>
Age:
</td>
<td>
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtAge" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="txtAge" ErrorMessage="18-40" MaximumValue="40"
MinimumValue="18" Type="Integer"></asp:RangeValidator>
</td>
</tr>
<tr>
<td>
Email Id:
</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtEmail" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmail" ErrorMessage="Invalid email"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
City:
</td>
<td>
<asp:DropDownList ID="CityDropDown" runat="server"
CausesValidation="True">
<asp:ListItem>Select</asp:ListItem>
<asp:ListItem>Pune</asp:ListItem>
<asp:ListItem>Mumbai</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ErrorMessage="Please select the city" ClientValidationFunction="CityValidate"
ControlToValidate="CityDropDown"></asp:CustomValidator>
</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" Text="Submit" Style="top: 211px; left: 125px;
position: absolute; height: 26px; width: 61px" />
</form>
</body>
</html>
[Purpose of this exercise is to use ADO.NET technology for showing records in Grid view from
Database .You can use Visual Studio .NET environment to type the program. Execution of
program in two ways.
1. Press F5 button OR
2. Right click on ASP.NET page (for e.g.: Default.aspx) and Select “View Browser” option and
select any browser for execution.
( Default.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Grid view control</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None">
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#E3EAEB" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</form>
</body>
</html>
‘Inline code( Default.aspx.vb)
Imports System.Data
Imports System.Data.SqlClient
Partial Class Default
Inherits System.Web.UI.Page
Dim con As String
Dim conn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As New DataSet
(Web.config)
<connectionStrings>
<add name="myConnection" connectionString="Data Source=JNEC02;Initial Catalog=JNEC;User
ID=sa;Password=sa"/>
</connectionStrings>
8. Lab Exercises:
[Purpose of this exercise is to use ADO.NET technology for inserting, updating and deleting
records from Database .You can use Visual Studio .NET environment to type the program.
Execution of program in two ways.
1. Press F5 button OR
2. Right click on ASP.NET page (for e.g.: Default.aspx) and Select “View Browser” option and
select any browser for execution.
</tr>
<tr>
<td>
Password:
</td>
<td>
<asp:TextBox ID="txtPwd" runat="server" Width="269px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Date of Birth(mm/dd/yyyy) :
</td>
<td>
<asp:TextBox ID="txtDOB" runat="server" Width="269px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Contact no:
</td>
<td>
<asp:TextBox ID="txtContact" runat="server" Width="269px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Email Id :
</td>
<td>
<asp:TextBox ID="txtEmail" runat="server" Width="269px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Gender :
</td>
<td>
<asp:RadioButtonList ID="RBL1" runat="server">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Button ID="btnInsert" runat="server" Text="Insert" />
<asp:Button ID="btnUpdate" runat="server" Text="Update" />
<asp:Button ID="btnDelete" runat="server" Text="Delete" />
<asp:Button ID="btnSearch" runat="server" Text="Search" />
</td>
</tr>
</table>
</form>
</body>
</html>
'Inserting Records
Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btnInsert.Click
Dim inQuery, gender As String
Try
con.Open()
If RBL1.SelectedIndex = 0 Then
gender = "M"
Else
gender = "F"
End If
inQuery = "Insert into Registration values('" & txtName.Text & "','" & txtPwd.Text & "','"
& Convert.ToDateTime(txtDOB.Text) & "'," & Convert.ToInt64(txtContact.Text) & " , '" &
txtEmail.Text & "' , '" & gender & "')"
cmd = New SqlCommand(inQuery, con)
cmd.ExecuteNonQuery()
Response.Write("Saved Successfully...")
con.Close()
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
[Purpose of this exercise is to use data list and repeater controls .You can use Visual Studio .NET
environment to type the program. Execution of program in two ways.
1. Press F5 button OR
2. Right click on ASP.NET page (for e.g.: Default.aspx) and Select “View Browser” option and
select any browser for execution.
( Default.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
( Player.xml)
<?xml version="1.0" encoding="utf-8" ?>
<Cricket>
<Team>
<Name>India</Name>
<Rank>1</Rank>
</Team >
<Team>
<Name>Australia</Name>
<Rank>2</Rank>
</Team >
</Cricket>
Exercise No10: ( 2 Hours) – 1 Practical
Lab Assignment 10: Web Services Demo.
Program:
Steps:
‘Webservice( myWebSerivce.vb)
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class myWebService
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
<WebMethod()> _
Public Function myFunction() As String
Return "This is myFunction in Webservice"
End Function
End Class
4. Quiz on the subject:
Quiz should be conducted on tips in the laboratory, recent trends and subject knowledge of the
subject. The quiz questions should be formulated such that questions are normally are from the
scope outside of the books. However twisted questions and self formulated questions by the
faculty can be asked but correctness of it is necessarily to be thoroughly checked before the
conduction of the quiz.
6. Submission:
Document Standard:
A] Page Size A4 Size
B] Running text Justified text
C] Spacing 1 Line
D] Page Layout and Margins (Dimensions in Cms)
Normal Page Horizantal
2.0
2.5
2.0
2.5 2.0
2.0
0.7”
0.7”
2.0
2.0
Desription Font Size Boldness Italics Underline Capitalize
College Name Arial 24 ----- ------ Yes ----------
Document Title Tahoma 22 ----- ------ --------- ----------
Document Subject Century Gothic 14 ----- ------ --------- Capital
Class Bookman old Slyle 12 ----- ------ --------- ----------
Document No Bookman old Slyle 10 ----- ------ --------- ----------
Copy write inf Bookman old Slyle 9 ----- ------ --------- ----------
Forward heading Bookman old Slyle 12 ----- ------ Yes Capital
Forward matter Bookman old Slyle 12 ----- ------ --------- ----------
Lab man Contents title Bookman old Slyle 12 ----- ------ Yes Capital
Index title Bookman old Slyle 12 Yes ------ Yes Capital
Index contents Bookman old Slyle 12 ----- ------ --------- ----------
Heading Tahoma 14 Yes Yes Yes ----------
Running Matter Comic Sans MS 10 ----- ------ --------- ----------
The marking patterns should be justifiable to the students without any ambiguity and teacher
should see that students are faced with unjust circumstances.