Web Technology (BCA Project Report)
Web Technology (BCA Project Report)
Web Technology (BCA Project Report)
PROJECT REPORT
ON
OF
2017-2018
Sharamjivi College, Ajmer
PROJECT EVALUATION SHEET
YEAR :- 2017-18
Vishesh Patni
Kushal Badgujar
Signature
(External Examinor)
This is to certify that the Internet Tools and Web Technology is the original work
done by VISHESH PATNI & KUSHAL BADGUJAR. The Report they prepared is
being submitted in partial fulfillment of Master of Computer Science requirement at
the …SHARAMJIVI College... Ajmer.
The content in this report is carried out under the guidance and cooperation of
______________________.
DATE ___/____/_2018_
Comments by examiner :
External Examiner
We undersigned , hearty declaration that the research project report written &
submitted by VISHESH PATNI & KUSHAL BADGUJAR undersigned under the
guidence of our lecturers & project guided by ___________________
It is our original work . The emperical finding in this project report are based on
“INTERNET TOOLS AND WEB TECHNOLOGY”.
We have not it from any were ,in case if any copying or use of unfair means is
justified against us then board id free athourity to take any presided actoin against us.
1. VISHESH PATNI
2. KUSHAL
BADGUJAR
Date:
Internet Basics
1. Introduction to HTML –
List Creating Table
Linking document
Frames
Graphics to HTML Doc
2. Style sheet –
Style sheet basic
Add style to document
Creating style sheet rules
3. Style sheet properties –
Font
Text
List
Color and Background color
Box
Display properties
Introduction to JavaScript
4. Advantage of JavaScript –
JavaScript syntax
Data type
Variable
Array
Operator and Expression
Looping Constructor
Function
Dialog box.
Current Servers
Google- http://www.google.com
Info seek- http://guide.infoseek.com
Alta Vista – http://www.altavista.digital.com
Sharamjivi College, Ajmer
Lycos – http://www.lycos.com
Yahoo! – http://www.yahoo.com
Domain
dakota tornado
Consists of 4 parts:
Directory
Filename
TCP/IP
TCP is a lossless protocol, requiring a handshake to insure that data is not lost
during transmission.
Internet Protocol (IP) uses addresses which are a series of four "octet" (byte)
numbers in a dotted decimal notation. For example: 199.246.24.130
Link Layer: This layer defines the networking methods with the scope of the
local network link on which hosts communicate without intervening routers.
This layer describes the protocols used to describe the local network topology
and the interfaces needed to affect transmission of Internet Layer datagram‘s
to next-neighbor hosts.
Internet Use:
History
To make a long story short, HTML was invented in 1990 by a scientist
called Tim Berners-Lee. The purpose was to make it easier for scientists at
different universities to gain access to each other's research documents
HTML Tags
HTML markup tags are usually called HTML tags
HTML tags are keywords surrounded by angle brackets like <html>
HTML tags normally come in pairs like <b> and </b>
The first tag in a pair is the start tag, the second tag is the end tag
Start and end tags are also called opening tags and closing tags
HTML Documents = Web Pages
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph</p> </body> </html>
Example Explained
The text between <html> and </html> describes the web page
The text between <body> and </body> is the visible page content
The text between <h1> and </h1> is displayed as a heading
The text between <p> and </p> is displayed as a paragraph
Tag Description
Basic
Formatting
Forms
Frames
<noframes> Defines an alternate content for users that do not support frames
Images
Links
<link /> Defines the relationship between a document and an external resource
Lists
Tables
<col /> Defines attribute values for one or more columns in a table
Styles
Meta Info
<base /> Defines a default address or a default target for all links on a page
<basefont /> Deprecated. Defines a default font, color, or size for the text in a page
Programming
<noscript> Defines an alternate content for users that do not support client-side scripts
Text property
This page deals with html tags for formatting a webpage with text and
will show how to create a headline, how to make paragraphs, how to pick fonts
and change their color and size .Use the H tag to create a headline, the h
tag comes in six flavors
<h6>Heading 6</h6>
Text align
Example
<H5 align=left>Hello World</H5>
Fonts are one of the most important visual elements of your page and if
you're like most web designers you'll want to set a few fonts in every page.
The font tag gives enough flexibility to allow html authors to specify
a 'back up' font
Font styles
use the <B></B> tags to make text <B>bold</B>
Horizontal Rule
Here's a horizontal rule... <hr /> ...that was a horizontal rule :)
Example Program
<html><body>
</center>
</body></html>
Listing Property
There are 3 different types of lists. A <ol> tag starts an ordered list, <ul> for
unordered lists, and <dl> for definition lists. Use the type and start attributes
to fine tune your lists accordingly.
NUMBERED LISTS
Plain numbers
Capital Letters
Small Letters
<ol><li>text</li> 1. text
<li>text</li></ol> 2. text
To create a hyperlink, you use the tag in conjunction with the href
attribute (href stands for Hypertext Reference). The value of the href attribute
is the URL, or, location of where the link is pointing to.
Hyper Link syntax:
The element content doesn't have to be text. You can link from an image or any
other HTML element.
Example:
Image Link
In HTML, images are defined with the <img> tag. The <img> tag is empty,
which means that it contains attributes only and it has no closing tag.
To display an image on a page, you need to use the src attribute. Src stands for
"source". The value of the src attribute is the URL of the image you want to
display on your page..
To embed an image into a web page, the image first needs to exist in either
.jpg, .gif, or .png format.
Example:
Src: This is the path to the image. It can be either an absolute path, or a
relative path
Width: This specifies the width to display the image. If the actual image is
wider, it will shrink to the dimensions you specify here. Likewise, if the actual
image is smaller it will expand to your dimensions. I don't recommend
specifying a different size for the image, as it will lose quality. It's better to
make sure the image is the correct size to start with.
Height: This specifies the height to display the image. This attribute works
similar to the width
Alt: Alternate text. This specifies text to be used in case the browser/user
agent can't render the image.
E-mail Link
<a href="mailto:dharmak07@gmail.com?subject=Hello%20Sir">
Send Mail</a>
Example Program
<html><body><p>
<a href="mailto:dharmak07@gmail.com?subject=Hello%20sir">
Send Mail</a></p>
</body></html>
HTML Colors
Colors are displayed combining RED, GREEN, and BLUE light.
The lowest value that can be given to one of the light sources is 0 (hex 00).
The highest value is 255 (hex FF).
Hex values are written as 3 double digit numbers, starting with a # sign.
Font color
Set the color of your font with color
Example:
Background Color :
Border color:
HTML Tables
Table property
Tag Description
<col> Defines the attribute values for one or more columns in a table
Example 1:
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Output:
Headings in a Table
<table border="1">
<tr>
<th>Heading</th>
<th>Another Heading</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
Sharamjivi College, Ajmer
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Output:
<th>Column 1</th>
<th>Column 2</th>
</table>
Output
<tr>
</table>
Output
Column 1 Column 2
HTML Frames
With frames, you can display more than one HTML document in the same
browser window. Each HTML document is called a frame, and each frame is
independent of the others.
The <frameset> tag defines how to divide the window into frames
The values of the rows/columns indicate the amount of screen area each
row/column will occupy
Attribute Description
rows Specifies the number of rows and their height in either pixels,
percentages, or relative lengths. Default is 100%
name Assigns a name to a frame. This is useful for loading contents into one
frame from another.
src Location of the frame contents (for example, the HTML page to be
loaded into the frame).
noresize Specifies whether the frame is resizable or not (i.e. whether the user can
resize the frame or not).
scrolling Whether the frame should be scrollable or not (i.e. should scrollbars
appear). Possible values:
auto
yes
no
frameborder Whether the frame should have a border or not. Possible values:
1 (border)
0 (no border)
marginwidth Specifies the margin, in pixels, between the frame's contents and it's left
and right margins.
marginheight Specifies the margin, in pixels, between the frame's contents and it's top
and bottom margins.
Example 1
<frameset cols="25%,75%">
<frame src="frame_a.htm">
<html>
<frameset rows="50%,50%">
<frame src="frame_a.htm">
<frameset cols="25%,75%">
<frame src="frame_b.htm">
Style sheet
cascading style sheets are now the standard way to define the
presentation of your HTML pages, from fonts and colours to the complete layout
of a page. They are much more efficient than using HTML on every page to
define the look of your site.
CSS Syntax
A CSS rule has two main parts: a selector, and one or more declarations:
The property is the style attribute you want to change. Each property has a
value.
CSS Example
<html> <head>
<style type="text/css">
P{
color:red;
text-align:center;
</style>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
CSS Background
background-color
background-image
background-repeat
background-attachment
background-position
Background Color
body {background-color:#b0c4de;}
Background Image
The background-image property specifies an image to use as the
background of an element.By default, the image is repeated so it covers the
entire element.
body {background-image:url('paper.gif');
body
{ background-image:url('gradient2.png'); }
Text Color
The color property is used to set the color of the text. The color can be
specified by:
Example
body {color:blue;}
h1 {color:#00ff00;}
h2 {color:rgb(255,0,0);
text-shadow none
color
length
unicode-bidi normal
embed
bidi-override
In CSS, there are two types of font family names:generic family - a group
of font families with a similar look (like "Serif" or "Monospace")
font family - a specific font family (like "Times New Roman" or "Arial")
Example
Example Program
<html> <head>
Sharamjivi College, Ajmer
<style type="text/css">
p.normal {font-weight:normal;}
p.light {font-weight:lighter;}
p.thick {font-weight:bold;}
p.thicker {font-weight:900;}
</style></head>
<body>
</body></html>
List
ordered lists - the list items are marked with numbers or letters
Example
CSS has several options for defining colors of both text and background areas
on your pages. These options can entirely replace the color attributes in plain
HTML. In addition, you get new options that you just didn't have in plain HTML.
Value Description
color <color>
transparent
background-color
<color>
none
background-image
url(<URL>)
repeat
repeat-x
background-repeat
repeat-y
no-repeat
scroll
background-attachment
fixed
<percentage>
<length>
top
background-position center
bottom
left
right
<html><head>
<style type="text/css">
body{
background-color:#d0e4fe;}
h1
color:orange;
text-align:center;
font-size:20px;
}</style></head>
<body>
<h1>CSS example!</h1>
<p>This is a paragraph.</p>
Sharamjivi College, Ajmer
</body></html>
All HTML elements can be considered as boxes. In CSS, the term "box model" is
used when talking about design and layout.
The CSS box model is essentially a box that wraps around HTML elements, and
it consists of: margins, borders, padding, and the actual content.
The box model allows us to place a border around elements and space elements
in relation to other elements
Margin - Clears an area around the border. The margin does not have a
background color, and it is completely transparent
Border - A border that lies around the padding and content. The border is
affected by the background color of the box
Padding - Clears an area around the content. The padding is affected by the
background color of the box
Content - The content of the box, where text and images appear
Example:
<html><head>
<style type="text/css">
div.ex
width:220px;
padding:10px;
margin:0px;
<body>
</body>
</html>
The display property specifies if/how an element is displayed, and the visibility
property specifies if an element should be visible or hidden.
Example
h1.hidden {visibility:hidden;}
Changing an inline element to a block element, or vice versa, can be useful for
making the page look a specific way, and still follow web standards.
li {display:inline;}
Example
<html><head>
<style type="text/css">
Span {
display:block;
</style> </head>
Sharamjivi College, Ajmer
<body>
<h2>Nirvana</h2>
<h2>Radiohead</h2>
<span>Record: OK Computer</span>
<span>Year: 1997</span></body></html>
JavaScript
Purpose
Provide an easy way to access cross-referenced documents that exist on the
internet .Purpose make web pages (documents) more dynamic and interactive
Change contents of document, provide forms and controls, animation, control
web browser window, etc.
Syntax
<html>
<body>
<script type="text/javascript">
//your script goes here
</script>
</body>
</html>
And
<script type="text/javascript" src=‘path.js‘> </script>
Mostly in the head section of HTML file, use script tags and then enclose in
comments
Example:
<html>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>
Elements of JavaScript
Variables
JavaScript is not a strongly typed language which means you rarely have
to concern yourself with the type of data a variable is storing, only what the
variable is storing and in JavaScript, variables can store anything, even
functions.
Syntax : var <variable Name> =value
<html><body>
<script type="text/javascript">
x=5+5;
document.write(x);
document.write("<br />");
var a=5,b=10,c;
c=a+b;
document.write(c);
document.write("<br />");
var oct=0377,x=10,res;
res=oct+x;
document.write(res);
x=5+"5";
Sharamjivi College, Ajmer
document.write(x);
document.write("<br />");
x="5"+5;
document.write(x);
document.write("<br />");
</script></body>
</html>
Array
Arrays are simply an ordered stack of data items with the same data type.
Using arrays, you can store multiple values under a single name. Instead of
using a separate variable for each item, you can use one array to hold all of
them.
Syntax
<html>
<body>
<script type="text/javascript">
document.write(fruits.sort());
</script></body>
</html>
<html>
<body>
<script type="text/javascript">
function sortNumber(a, b)
document.write(n.sort(sortNumber));
</script></body>
</html>
Dynamic Arrays:
In many a cases we will not want to create the array with a fixed size or
length. In such cases we can create an array with out passing length. This array
will dynamically set its value as and when a new variable or entry is added
Looping Constructor
If Statement
Use the if statement to execute some code only if a specified condition is true.
Syntax
if (condition)
{
code to be executed if condition is true
}
If...else Statement
Use the if....else statement to execute some code if a condition is true and
another code if the condition is not true.
Syntax
if (condition)
{
code to be executed if condition is true
}
else
Sharamjivi College, Ajmer
{
code to be executed if condition is not true
}
Example
<html><body>
<script type="text/javascript">
var a=5,b=10;
if(a>b)
document.write("A is big");
}else
document.write("B is big");
Switch Statement:
Use the switch statement to select one of many blocks of code to be executed.
Syntax
switch(n)
{
case 1:
execute code block 1
break;
case 2:
execute code block 2
break;
default:
code to be executed if n is different from case 1 and 2
}
Example
<html><body>
<script type="text/javascript">
switch (theDay)
case 1: document.write("SUNDAY")
break;
break;
break;
default:
while Loop
The while loop loops through a block of code while a specified condition is true.
Syntax
while (var<=endvalue)
{
code to be executed
}
Example
<html> <body>
<script type="text/javascript">
i=0
while (i <= 5)
document.write("<br>")
i++
do...while Loop
The do...while loop is a variant of the while loop. This loop will execute the
block of code ONCE, and then it will repeat the loop as long as the specified
condition is true.
Syntax
do
{
code to be executed
}
while (var<=endvalue);
Example
<script language="javascript">
var i=0;
do
while(i!=0)
</script>
for Loop
The for loop is used when you know in advance how many times the script
should run.
Syntax
Example
<html> <body>
<script type="text/javascript">
document.write("<br>")
Function
You may call a function from anywhere within a page (or even from other pages
if the function is embedded in an external .js file).
Functions can be defined both in the <head> and in the <body> section of a
document.
Syntax
function functionname(var1,var2,...,varX)
{
some code
}
Example
<html> <head>
function myfunction(txt)
alert(txt)
</script>
</head>
<body>
<form>
</form>
</body> </html>
The return statement is used to specify the value that is returned from the
function. So, functions that are going to return a value must use the return
statement.
Example
<html>
<head>
<script type="text/javascript">
function total(numberA,numberB)
</script>
</head>
<script type="text/javascript">
document.write(total(2,5))
</script>
</body>
</html>
Dialog box
JavaScript supports three important types of dialog boxes. These dialog boxes
can be used to raise and alert, or to get confirmation on any input or to have a
kind of input from the users.
The alert() method displays an alert box with a specified message and an OK
button.
Syntax
alert(message)
Example
<html>
<head>
<script type="text/javascript">
function display()
</script>
</head>
<body>
</html>
The prompt dialog box is very useful when you want to pop-up a text box to get
user input
Syntax
prompt(msg,defaultText)
Example
<html> <head>
<script type="text/javascript">
function dispprompt()
</script>
</head>
<body>
<div id="msg"></div>
</body>
</html>
Syntax
confirm(message)
Example
<html><head>
<script type="text/javascript">
function display()
</body> </html>
The Document object provides access to all HTML elements in a page, from
within a script.
The Document object is also part of the Window object, and can be accessed
through the window.document property.
Collection Description
Anchors
The anchors collection returns an array of all the anchors in the current
document.
Syntax
document.anchors[].property
Example
<html>
<body>
<script type="text/javascript">
document.write(document.anchors.length);</script></p>
</body>
</html>
forms
The forms collection returns an array of all the forms in the current document
Syntax
document.forms[].property
Example
<html>
<body>
<form name="Form1"></form>
Sharamjivi College, Ajmer
<form name="Form2"></form>
<p>Number of forms:
<script type="text/javascript">
document.write(document.forms.length);
</script></p>
</body>
</html>
images
The images collection returns an array of all the images in the current
document.
Syntax
document.images[].property
Example:
<html>
<body>
<img border="0" src="a.jpg" width="150" height="113" />
<img border="0" src="b.jpg" width="152" height="128" />
<p>Number of images:
<script type="text/javascript">
document.write(document.images.length);
</script></p></body> </html>
Links
The links collection returns an array of all the links in the current document.
The links collection counts
<a href=""> tags and <area> tags.
Syntax
document.links[].property
Example
<html>
<body>
Sharamjivi College, Ajmer
<a href="images.html">Images</a>
<p>Number of areas/links:
<script type="text/javascript">
document.write(document.links.length);
</script>
</p>
</body>
</html>
Javascript is an Event Driven Language
Javascript is an event driven language which means your scripts react to events
you set up. Your code isn't running all the time, it simply waits until an event
starts something up! Going into all the Javascript events is beyond the scope.
Syntax
window.open(URL,name,specs)
Reload window
To reload a window, use this method:
window.location.reload()
Close Window
The closed property returns a Boolean value indicating whether a window has
been closed or not.
Syntax
window.close()
<html>
<head>
<script type="text/javascript">
function openWin()
{
myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>This is 'myWindow'</p>");
}
function closeWin()
{
myWindow.close();
}
function Relo()
{
setInterval() method
The setInterval() method calls a function or evaluates an expression at
specified intervals (in milliseconds).
1000 ms = 1 second.
Syntax
setInterval(―windowname‖,millisec)
Eg:
setTimeout("alert('hi!');", 500);
Navigator Object
The navigator object contains information about the browser.
Property Description
appCodeName Returns the code name of the browser
appName Returns the name of the browser
appVersion Returns the version information of the browser
cookieEnabled Determines whether cookies are enabled in the browser
Navigator Syntax
navigator.appCodeName
navigator.appName
navigator.appVersion
navigator.cookieEnabled
navigator.platform
navigator.userAgent
Example
<html>
<body>
<script type="text/javascript">
document.write("Browser CodeName: " + navigator.appCodeName);
document.write("<br /><br />");
document.write("Browser Name: " + navigator.appName);
document.write("<br /><br />");
document.write("Browser Version: " + navigator.appVersion);
document.write("<br /><br />");
document.write("Cookies Enabled: " + navigator.cookieEnabled);
document.write("<br /><br />");
document.write("Platform: " + navigator.platform);
document.write("<br /><br />");
document.write("User-agent header: " + navigator.userAgent);
</script></body>
</html>
Screen object
Example
<HTML>
<BODY>
<script type="text/javascript">
document.write("Available Height: " + screen.availHeight);
document.write("</br>Available Width: " + screen.availWidth);
document.write("</br>Color Depth: " + screen.colorDepth);
document.write("</br>Total Height: " + screen.height);
document.write("</br>Color resolution: " + screen.pixelDepth);
document.write("</br>Total Width: " + screen.width);
</script>
</BODY>
</HTML>
Form Object
form object is a Browser object of JavaScript used to access an HTML form. If a
user wants to access all forms within a document then he can use the forms
array.
The form object is actually a property of document object that is uniquely
created by the browser for each form present in a document.
The properties and methods associated with form object are used to access the
form fields, attributes and controls associated with forms.
<HTML>
<HEAD>
<TITLE>Test Input</TITLE>
</HEAD>
<BODY>
<FORM NAME="myform" ACTION="" METHOD="GET">Enter box: <BR>
Syntax
var txt = new String(string);
String Object Methods
Method Description
search() Searches for a match between a regular expression and a string, and
returns the position of the match
slice() Extracts a part of a string and returns a new string
split() Splits a string into an array of substrings
substr() Extracts the characters from a string, beginning at a specified start
position, and through the specified number of character
substring() Extracts the characters from a string, between two specified indices
<html>
<body>
<script type="text/javascript">
var str="Hello world!";
document.write("First character: " + str.charAt(0) + "<br />");
document.write("Unicode of first character: " + str.charCodeAt(0) + "<br />");
document.write(str.indexOf("Hello") + "<br />");
document.write(str.toLowerCase()+"<br />");
document.write(str.toUpperCase()+"<br />");
document.write(str.valueOf()+"<br />")
var str1="Hello ";
var str2="Dharma!";
var str3=" Have a nice day!";
document.write(str1.concat(str2,str3)+ "<br />");
document.write(String.fromCharCode(72,69,76,76,79)+ "<br />");
document.write(str.lastIndexOf("Hello") + "<br />");
var str1="The rain in SPAIN stays mainly in the plain";
Date Object
Example
Math Object
Syntax
var x = Math.PI; // Returns PI
var y = Math.sqrt(16); // Returns the square root of 16
Property Description
Example
<html>
<body>
<script type="text/javascript">
document.write("abs"+Math.abs(7.25) + "<br />");
document.write("acos"+Math.acos(0.64) + "<br />")
document.write("asin"+Math.asin(0.64) + "<br />")
document.write("atan2"+Math.atan2(8,4)+ "<br />");
document.write("ceil"+Math.ceil(0.60) + "<br />");
document.write("cos"+Math.cos(3) + "<br />");
document.write("floor"+Math.floor(0.60) + "<br />")
document.write("log"+Math.log(1) + "<br />");
document.write("max"+Math.max(-5,10) + "<br />");
document.write("pow"+Math.pow(0,0) + "<br />");
document.write("rount"+Math.round(0.60) + "<br />");
document.write("random"+Math.random() + "<br />");
document.write("sin"+Math.sin(3) + "<br />");
document.write("sqrt"+Math.sqrt(9) + "<br />");
</script>
</body>
</html>
All user-defined objects and built-in objects are descendants of an object called
Object. .
The new Operator:
Sharamjivi College, Ajmer
The new operator is used to create an instance of an object. To create an
object, the new operator is followed by the constructor method.
Example
<html>
<head>
<title>User-defined objects</title>
<script type="text/javascript">
var book = new Object(); // Create the object
book.subject = "C++"; // Assign properties to the object
book.author = "Balagurusami";
</script>
</head>
<body>
<script type="text/javascript">
document.write("Book name is : " + book.subject + "<br>");
document.write("Book author is : " + book.author + "<br>");
</script>
</body>
</html>
cookies
Cookies are small amounts of data stored by the web browser. They allow you
to store particular information about a user and retrieve it every time they visit
your pages.Each user has their own unique set of cookies.
syntax
name=value This sets both the cookie's name and its value.
Ex : username=AAAA
expires=date This optional value sets the date that the cookie will expire on.
The date should be in the format returned by the the toGMTString() method of
the Date object – Greenwith Mean Time(DD-MM-YY)
expires=13/06/2003 00:00:00
domain=domain This optional value specifies a domain within which the
cookie applies. Only websites in this domain will be able to retrieve the cookie
Ex : domain=google.com
secure : This optional flag indicates that the browser should use SSL when
sending the cookie to the server. This flag is rarely used.
Example
<html>
<head>
<script type="text/javascript">
<!--
function WriteCookie()
{
if( document.myform.customer.value == "" )
{
alert("Enter some value!");
return;
}
cookievalue= escape(document.myform.customer.value) + ";";
document.cookie="name=" + cookievalue;
alert("Setting Cookies : " + "name=" + cookievalue );
}
//-->
</script>
</head>
<body>
<form name="myform" action="">
Enter name: <input type="text" name="customer"/>
<input type="button" value="Set Cookie" ></form>
</body>
</html>
What is ASP.NET?
Features of ASP.NET
When an ASP.NET page runs, the page goes through a life cycle in which it
performs a series of processing steps. These include initialization, instantiating
controls, restoring and maintaining state, running event handler code, and rendering.
It is important for you to understand the page life cycle so that you can write code at
the appropriate life-cycle stage for the effect you intend. Additionally, if you develop
custom controls, you must be familiar with the page life cycle in order to correctly
initialize controls, populate control properties with view-state data, and run any control
behavior code. (The life cycle of a control is based on the page life cycle, but the page
raises more events for a control than are available for an ASP.NET page alone.)
In general terms, the page goes through the stages outlined in the following table. In
addition to the page life-cycle stages, there are application stages that occur before and after a
request but are not specific to a page.
Stage Description
Page request The page request occurs before the page life cycle begins. When the page is
requested by a user, ASP.NET determines whether the page needs to be parsed
and compiled (therefore beginning the life of a page), or whether a cached
version of the page can be sent in response without running the page.
Start In the start step, page properties such as Request and Response are set. At this
stage, the page also determines whether the request is a postback or a new
request and sets the IsPostBack property. Additionally, during the start step,
the page's UICulture property is set.
Life-cycle Events
Within each stage of the life cycle of a page, the page raises events that you can handle to run
your own code. For control events, you bind the event handler to the event, either declaratively
using attributes such as onclick, or in code.
Pages also support automatic event wire-up, meaning that ASP.NET looks for methods with
particular names and automatically runs those methods when certain events are raised. If the
AutoEventWireup attribute of the @ Page directive is set to true (or if it is not defined, since
by default it is true), page events are automatically bound to methods that use the naming
convention of Page_event, such as Page_Load and Page_Init
The following table lists the page life-cycle events that you will use most frequently.
There are more events than those listed; however, they are not used for most page processing
scenarios. Instead, they are primarily used by server controls on the ASP.NET Web page to
initialize and render themselves. If you want to write your own ASP.NET server controls, you
need to understand more about these stages.
Note
Init Raised after all controls have been initialized and any skin settings have
been applied. Use this event to read or initialize control properties.
InitComplete Raised by the Page object. Use this event for processing tasks that require
all initialization be complete.
PreLoad Use this event if you need to perform processing on your page or control
before the Load event.
After the Page raises this event, it loads view state for itself and all
controls, and then processes any postback data included with the Request
instance.
Load The Page calls the OnLoad event method on the Page, then recursively
does the same for each child control, which does the same for each of its
child controls until the page and all controls are loaded.
Use the OnLoad event method to set properties in controls and establish
database connections.
Control events Use these events to handle specific control events, such as a Button
control's Click event or a TextBox control's TextChanged event.
Note
LoadComplete Use this event for tasks that require that all other controls on the page be
loaded.
PreRender Before this event occurs:
The Page object calls EnsureChildControls for each control and for the
page.
Each data bound control whose DataSourceID property is set calls its
DataBind method. For more information, see Data Binding Events for
Data-Bound Controls below.
The PreRender event occurs for each control on the page. Use the event
to make final changes to the contents of the page or its controls.
SaveStateComplete Before this event occurs, ViewState has been saved for the page and for all
controls. Any changes to the page or controls at this point will be ignored.
Use this event perform tasks that require view state to be saved, but that
do not make any changes to controls.
Render This is not an event; instead, at this stage of processing, the Page object
calls this method on each control. All ASP.NET Web server controls have a
Render method that writes out the control's markup that is sent to the
browser.
If you create a custom control, you typically override this method to output
the control's markup. However, if your custom control incorporates only
standard ASP.NET Web server controls and no custom markup, you do not
Note
During the unload stage, the page and its controls have been rendered,
so you cannot make further changes to the response stream. If you
attempt to call a method such as the Response.Write method, the page
will throw an exception.
Structure of Asp.Net
Directives
You can use directives to specify optional settings used by the page compiler
when processing ASP.NET files. For each directive you can set different
attributes. One example is the language directive at the beginning of a page
defining the default programming language.
Code declaration blocks are lines of code enclosed in <script> tags. They contain the
runat=server attribute, which tells ASP.NET that these controls can be accessed on the server
and on the client. Optionally you can specify the language for the block. The code block itself
consists of the definition of member variables and methods.
Render blocks contain inline code or inline expressions enclosed by the character sequences
shown here. The language used inside those blocks could be specified through a directive like
the one shown before.
You can declare several standard HTML elements as HTML server controls. Use the element as
you are familiar with in HTML and add the attribute runat=server. This causes the HTML
element to be treated as a server control. It is now programmatically accessible by using a
unique ID. HTML server controls must reside within a <form> section that also has the attribute
runat=server.
You can create bindings between server controls and data sources. The data binding expression
is enclosed by the character sequences <%# and %>. The data-binding model provided by
ASP.NET is hierarchical. That means you can create bindings between server control properties
and superior data sources.
If you need to create an instance of an object on the server, use server-side object tags. When
the page is compiled, an instance of the specified object is created. To specify the object use
the identifier attribute. You can declare .NET objects using class as the identifier, and COM
objects using either progid or classid.
With server-side include directives you can include raw contents of a file anywhere in your
ASP.NET file. Specify the type of the path to filename with the path type attribute. Use either
File, when specifying a relative path, or Virtual, when using a full virtual path.
Server-side Comments
To prevent server code from executing, use these character sequences to comment it out. You
can comment out full blocks - not just single lines.
Asp.Net – Framework
ASP.NET is based on the fundamental architecture of .NET Framework. Visual studio provides a
uniform way to combine the various features of this Architecture. Architecture is explained form
bottom to top in the following discussion.
1..NET Framework provides a rich set of class libraries. These include base classes, like
networking and input/output classes, a data class library for data access, and classes for use by
programming tools, such as debugging services. All of them are brought together by the
Services Framework, which sits on top of the common language runtime.
2. ADO.NET is Microsoft‘s ActiveX Data Object (ADO) model for the .NET Framework. ADO.NET
is not simply the migration of the popular ADO model to the managed environment but a
completely new paradigm for data access and manipulation.
ADO.NET is intended specifically for developing web applications. This is evident from its two
major design principles:
>>Disconnected Datasets—In ADO.NET, almost all data manipulation is done outside the
context of an open database connection.
>>Effortless Data Exchange with XML—Datasets can converse in the universal data format of
the Web, namely XML.
3. The 4th layer of the framework consists of the Windows application model and, in parallel,
the Web application model.
The Web application model-in the slide presented as ASP.NET-includes Web Forms and Web
Services. ASP.NET comes with built-in Web Forms controls, which are responsible for
generating the user interface. They mirror typical HTML widgets like text boxes or buttons. If
these controls do not fit your needs, you are free to create your own user controls. Web
Services brings you a model to bind different applications over the Internet. This model is
based on existing infrastructure and applications and is therefore standard-based, simple, and
adaptable. Web Services are software solutions delivered via Internet to any device. Today,
that means Web browsers on computers, for the most part, but the device-agnostic design of
.NET will eliminate this limitation.
4. One of the obvious themes of .NET is unification and interoperability between various
programming languages. In order to achieve this; certain rules must be laid and all the
languages must follow these rules. In other words we can not have languages running around
creating their own extensions and their own fancy new data types. CLS is the collection of the
rules and constraints that every language (that seeks to achieve .NET compatibility) must
follow.
5.The CLR and the .NET Frameworks in general, however, are designed in such a way that code
written in one language can not only seamlessly be used by another language. Hence ASP.NET
can be programmed in any of the .NET compatible language whether it is VB.NET, C#, Managed
C++ or JScript.NET.
Types of Controls:
1. Web Controls
2. Html Controls
3. Validation Controls
4. User Controls
1. Web Controls:
Web Controls provide a more consistent object model and a higher level of abstraction than
HtmlControls
– Most HTML elements can also be represented as Web Controls on the server
– Web Control versions typically have a more consistent interface (background color is always
Back Color property whereas in HTML it may be a style attribute (span) or a property (table) )
– Web Controls also provide higher-level controls with more functionality than primitive HTML
elements (like the Calendar control)
– Web Controls may render themselves differently based on client browser capabilities
Web controls
Button DropDownList
Calendar ListBox
CheckBox Panel
RadioButton Table
HyperLink TableRow
Textbox TableCell
<body>
<form runat="Server">
</form>
</body>
</html>
1.HTML Controls:
– Any HTML element in an ASPX page marked with the runat=server attribute will become an
HTML control on the server
– HTML elements with no distinguished server-side functionality (like div, span, etc.) are all
represented as HtmlGenericControl instances
Html Controls
HtmlInputFile HtmlButton
HtmlInputHidden HtmlSelect
HtmlInputRadioButton HtmlTable
HtmlInputText HtmlTableCell
HtmlInputButton HtmlTableRow
HtmlInputCheckButton HtmlTextArea
HtmlInputImage HtmlAnchor
HtmlAnchor
Sharamjivi College, Ajmer
The Anchor control to programmatically control an <a> HTML element. The <a> HTML
element allows you to create a hyperlink that allows you to move to another location on the
page or to another Web page. The HtmlAnchor control must be well formed with an opening
and closing tag.
Remember to embed the HtmlAnchor control inside the opening and closing tags of
an HtmlForm control.
HtmlButton Button control to program against the HTML <button> element. You can provide
custom code for the ServerClick event of the HtmlButtoncontrol to specify the action
performed when the control is clicked.
The HtmlButton control renders JavaScript to the client browser. The client browser must
have JavaScript enabled for this control to function properly
Declare an HtmlButton control on your Web Forms pag
HtmlForm
Form control to program against the HTML <form> element. To take advantage of the
postback services, all Web Forms controls, whether HTML, Web, pagelet, or custom, must be
nested between well-formed opening and closing tags of the HtmlForm control. If the tags are
not closed properly, ASP.NET will not recognize the element. The element will either be ignored
or a compilation error will occur, depending on how the element is formed.
HtmlTable
Table control to program against the HTML <table> element. An HtmlTable control is made
up of rows (represented by HtmlTableRowobjects) stored in the Rows collection of a table. Each
row is made up of cells (represented by HtmlTableCell objects) stored in the Cells collection of a
row.
To create a table, first declare an HtmlTable control in the form on your page. Next,
place HtmlTableRow objects between the opening and closing tags of the HtmlTable control,
one for each row you want in your table. Once the rows of the table are defined,
declare HtmlTableCell objects between the opening and closing tags of
each HtmlTableRow object to create the cells of the row.
<tr>
Sharamjivi College, Ajmer
<td></td>
</tr>
</table>
HtmlInputFile
File control to program against the HTML <input type=file> element. You can use
the HtmlInputFile control to easily design a page that allows users to upload binary or text
files from a browser to a directory that you designate on your Web server. File upload is
enabled in all HTML 3.2 and later Web browsers.
Label control
Used to display text in a set location on the page. Unlike static text, you can customize the
displayed text by setting the Text property.
Button control
The Button control allows you to create a push button on the Web Forms page. There are two
types of buttons that can be created. You can create either a submit button or
a command button.
CheckBox control
The CheckBox control creates a check box on the Web Forms page that allows the user to
switch between a true or false state. You can specify the caption to display in the control by
setting the Text property. The caption can appear either on the right or left of the check box.
Set the TextAlignproperty to specify the side that the caption appears on.
HyperLink control
Use the HyperLink control to create a link that moves you to another page or location on the
page. Specify the page or location to link to by using theNavigateUrl property. The link can
either be displayed as text or an image. To display text, either set the Text property or simply
place the text between the opening and closing tags of the HyperLink control. To display an
image, set the ImageUrl property.
Image control
Use the Image control to display an image on the Web Forms page. Setting
the ImageUrl property specifies the path to the displayed image. You can specify the text
to display in place of the image when the image is not available by setting
the AlternateText property. The ImageAlign property specifies the alignment of the image in
relation to other elements on the Web Forms page.
This control only displays an image. If you want the image to behave like a button or need to
determine the coordinates where the mouse pointer is clicked on the image, use
the ImageButton control.
RadioButton
The RadioButton server control creates a radio button on the Web Forms page. Specify the
text to display in the control by setting Text property. The text can appear either on the left or
the right of the radio button. Set TextAlign property to control the side that the text appears
on. You can group multiple radio buttons together if you specify the same GroupName for
each RadioButton control. Grouping radio buttons together will only allow a mutually exclusive
selection from the group.
The TextBox server control is an input control that lets the user enter text. By default,
the TextMode property is set to SingleLine, which creates a text box with only one line. You
can also set the property to MultiLine or Password. MultiLine creates a text box with more
than one line. Password creates a single-line text box that masks the value entered by the
user. The display width of the text box is determined by its Columns property. If the text box
is a multiline text box, the display height is determined by theRows property.
CheckBoxList control
The CheckBoxList control creates a multiselection check box group that can be dynamically
generated using data binding. To specify items that you want to appear in
the CheckBoxList control, place a ListItem element for each entry between the opening and
closing tags of the CheckBoxList control.
DropDownList control
Use the DropDownList control to create a single selection drop-down list control. You can
control the appearance of the DropDownList control by setting
the BorderColor, BorderStyle, and BorderWidth properties.
To specify the items that appear in the DropDownList control, place a ListItem element for
each entry between the opening and closing tags of theDropDownList control.
Example
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Text="a" Value="1"></asp:ListItem>
<asp:ListItem Text="b" Value="2"></asp:ListItem
</asp:RadioButtonList>
ImageButton control
Use the ImageButton control to display an image that responds to mouse clicks. Specify the
image to display in the control by setting the ImageUrlproperty.
Both the Click and Command events are raised when the ImageButton control is clicked.
Use the ListBox control to create a list control that allows single or multiple item selection. Use
the Rows property to specify the height of the control. To enable multiple item selection, set
the SelectionMode property to ListSelectionMode.Multiple.
To specify the items that you want to appear in the ListBox control, place a ListItem element
for each entry between the opening and closing tags of theListBox control.
Syntex
<asp:DataGrid ID="DataGrid1" runat="server"> </asp:DataGrid>
The order that the columns are displayed in the DataGrid control is controlled by the order
that the columns appear in the Columnscollection. Although you can programmatically change
the order of the columns by manipulating the Columns collection, it is easier to list the
columns in the desired display order.
Explicitly declared columns can be used in conjunction with automatically generated columns.
When using both, explicitly declared columns will be rendered first, followed by the
automatically generated columns. Automatically generated columns are not added to
theColumns collection.
Example
<Script Runat="Server">
Sub Page_Load
conNorthwind=New SqlConnection(
"Server=localhost;UID=sa;PWD=secret;Database=Northwind" )
conNorthwind.Open()
dgrdEmployees.DataSource = cmdSelect.ExecuteReader()
dgrdEmployees.DataBind()
conNorthwind.Close()
End Sub
</Script>
<html><head><title>ExpertDataGrid.aspx</title></head>
The Repeater control is different from other data list controls in that it allows
you to place HTML fragments in its templates. This allows you to create a
complex HTML structure, such as a table. For example, to create a list within an
HTML table, start the table by placing the <table> tag in
theHeaderTemplate. Next, create the rows and columns of the table by
placing <tr> tags, <td> tags, and data-bound items in the ItemTemplate. If
you want a different appearance for alternating items in the table, create
an AlternatingItemTemplate with the same contents as the ItemTemplate,
except with a different style specified. Finally, complete the table by placing
the </table> tag in the FooterTemplate.
<asp:Repeater id="Repeater1"
DataSource="<% databindingexpression %>"
runat=server>
<HeaderTemplate>
Header template HTML
</HeaderTemplate>
<ItemTemplate>
Item template HTML
</ItemTemplate>
<AlternatingItemTemplate>
Alternating item template HTML
</AlternatingItemTemplate>
<SeparatorTemplate>
Separator template HTML
</SeparatorTemplate>
<FooterTemplate>
Footer template HTML
</FooterTemplate>
<asp:Repeater>
Cookies provide a means in Web applications to store user-specific information. For example,
when a user visits your site, you can use cookies to store user preferences or other information.
When the user visits your Web site another time, the application can retrieve the information it
stored earlier.
A cookie is a small bit of text that accompanies requests and pages as they go between the
Web server and browser. The cookie contains information the Web application can read
whenever the user visits the site.
For example, if a user requests a page from your site and your application sends not just a
page, but also a cookie containing the date and time, when the user's browser gets the page,
the browser also gets the cookie, which it stores in a folder on the user's hard disk.
Later, if user requests a page from your site again, when the user enters the URL the browser
looks on the local hard disk for a cookie associated with the URL. If the cookie exists, the
browser sends the cookie to your site along with the page request. Your application can then
determine the date and time that the user last visited the site. You might use the information to
display a message to the user or check an expiration date.
Cookies are associated with a Web site, not with a specific page, so the browser and server will
exchange cookie information no matter what page the user requests from your site. As the user
visits different sites, each site might send a cookie to the user's browser as well; the browser
stores all the cookies separately.
Cookies help Web sites store information about visitors. More generally, cookies are one way of
maintaining continuity in a Web application—that is, of performing state management. Except
for the brief time when they are actually exchanging information, the browser and Web server
are disconnected. Each request a user makes to a Web server is treated independently of any
other request. Many times, however, it's useful for the Web server to recognize users when
they request a page. For example, the Web server on a shopping site keeps track of individual
shoppers so the site can manage shopping carts and other user-specific information. A cookie
therefore acts as a kind of calling card, presenting pertinent identification that helps an
application know how to proceed.
Cookies are used for many purposes, all relating to helping the Web site remember users. For
example, a site conducting a poll might use a cookie simply as a Boolean value to indicate
whether a user's browser has already participated in voting so that the user cannot vote twice.
A site that asks a user to log on might use a cookie to record that the user already logged on so
that the user does not have to keep entering credentials.
You can add cookies to the Cookies collection in a number of ways. The following example
shows two methods to write cookies:
Response.Cookies("userName").Value = "patrick"
Response.Cookies("userName").Expires = DateTime.Now.AddDays(1)
ADO .NET
Most applications need data access at one point of time making it a crucial component when
working with applications. Data access is making the application interact with a database,
where all the data is stored. Different applications have different requirements for database
access. ASP.NET uses ADO .NET (Active X Data Object) as it's data access and manipulation
protocol which also enables us to work with data on the Internet.
Advantages of ADO.Net
OLEDB
The dot net framework data provider for OLEDB provides connectivity with the OLEDB
supported database management systems. It is the recommended middle tier for the SQL
Server 6.5 or earlier and Microsoft Access Database. It is a general data provider. You can also
use it to connect with the SQL Server or Oracle Database Management Systems. The classes for
this provider are present in the System.Data.OleDBClient namespace.
Dataset
Data Provider
Sharamjivi College, Ajmer
The Data Provider is responsible for providing and maintaining the connection to the database.
A DataProvider is a set of related components that work together to provide data in an efficient
and performance driven manner. The .NET Framework currently comes with two
DataProviders: the SQL Data Provider which is designed only to work with Microsoft's SQL
Server 7.0 or later and the OleDb DataProvider which allows us to connect to other types of
databases like Access and Oracle. Each DataProvider consists of the following component
classes:
A connection object establishes the connection for the application with the database. The
command object provides direct execution of the command to the database. If the command
returns more than a single value, the command object returns a DataReader to provide the
data. Alternatively, the DataAdapter can be used to fill the Dataset object. The database can be
updated using the command object or the DataAdapter.
The Connection object creates the connection to the database. Microsoft Visual Studio .NET
provides two types of Connection classes: the SqlConnection object, which is designed
specifically to connect to Microsoft SQL Server 7.0 or later, and the OleDbConnection object,
which can provide connections to a wide range of database types like Microsoft Access and
Oracle. The Connection object contains all of the information required to open a connection to
the database.
ExecuteNonQuery: Executes commands that have no return values such as INSERT, UPDATE or
DELETE
ExecuteScalar: Returns a single value from a database query
ExecuteReader: Returns a result set by way of a DataReader object
The DataReader object provides a forward-only, read-only, connected stream recordset from a
database. Unlike other components of the Data Provider, DataReader objects cannot be directly
instantiated. Rather, the DataReader is returned as the result of the Command object's
ExecuteReader method. The SqlCommand.ExecuteReader method returns a SqlDataReader
object, and the OleDbCommand.ExecuteReader method returns an OleDbDataReader object.
The DataReader can provide rows of data directly to application logic when you do not need to
keep the data cached in memory. Because only one row is in memory at a time, the
DataReader provides the lowest overhead in terms of system performance but requires the
exclusive use of an open Connection object for the lifetime of the DataReader.
The DataAdapter is the class at the core of ADO .NET's disconnected data access. It is
essentially the middleman facilitating all communication between the database and a DataSet.
The DataAdapter is used either to fill a DataTable or DataSet with data from the database with
it's Fill method. After the memory-resident data has been manipulated, the DataAdapter can
commit the changes to the database by calling the Update method. The DataAdapter provides
four properties that represent database commands:
SelectCommand
InsertCommand
DeleteCommand
UpdateCommand
When the Update method is called, changes in the DataSet are copied back to the database and
the appropriate InsertCommand, DeleteCommand, or UpdateCommand is executed.
Internet Information Services is used to make your computer a web server. If we want
to have a web server for developing dynamic website or want to publish website on our
own server then we install the IIS. IIS is used on windows plate form.
IIS takes request from user and executes the required files and sends result back to
the user. IIS server also provides the services of SMTP (Simple Mail Transport
Protocol). We can send emails using SMTP. FrontPage server extensions are also the
part of IIS
IIS Features
IIS 7 is built on a modular architecture. Modules, also called extensions, can be added
or removed individually so that only modules required for specific functionality have to
be installed. IIS 7 includes native modules as part of the full installation. These
modules are individual features that the server uses to process requests and include
the following:
Logging and Diagnostics modules - Used to perform tasks related to logging and
diagnostics in the request-processing pipeline, such as passing information and
processing status to HTTP.sys for logging, reporting events, and tracking requests
currently executing in worker
E-mail is one of the most common and reliable methods of communication for both personal
and business purposes. It also plays an important role in each and every Web site. This role will
be in the type of automated e-mails from the server after posting information from a form. You
may have noticed these types of e-mails while registering on a site.
The .NET Framework makes the task of sending email from a Web page relatively simple. In
order to send an email from an ASP.NET Web page you need to use the SmtpMail class found in
the System.Web.Mail namespace, which contains a static method Send.
We are using System.Web.Mail.SmtpMail to send email in dotnet 1.1 which is obsolete in 2.0.
The System.Net.Mail.SmtpClient Class will provide us the same feature as that of its
predecessor.
Sending Email
Using System.IO;
Using System.Web.Mail;
mm.Attachments.Add(ma);
SmtpMail.SmtpServer="mail.programmersheaven.com";
SmtpMail.Send(mm);
Because of ASP.NET‘s improved object model, much of the functionality of the Request
and Response objects has been deprecated. There remain other uses for these objects.
You can work with cookies, redirect users, check browser capabilities and even send
binary information down the output stream.
QueryString
The QueryString collection is used to retrieve the variable values in the HTTP query
string.
The HTTP query string is specified by the values following the question mark (?), like
this:
The line above generates a variable named txt with the value "this is a query string
test".
Query strings are also generated by form submission, or by a user typing a query into
the address bar of the browser.
Request.QueryString(variable)[(index)|.Count]
Syntax
Request.Form(element)[(index)|.Count]
Example:
ServerVariables Collection
The ServerVariables collection is used to retrieve the server variable values.
Syntax
Request.ServerVariables (server_variable)
Example
ASP.NET Security
Authentication is simply establishing the identity of the user. In the secure office
building, every person must have an ID badge. Each person who works in the building
might be issued a cardkey or badge to display, and a visitor might be asked to wear a
temporary ID.
Syntax
<configuration>
<system.web>
<authentication
mode = " [ Windows | Forms | Passport | None ] ">
</authentication>
</system.web>
</configuration>
SSL Secured
This can be a requirement because SSL increases the CPU load on the web server and
can limit scalability. Often you need SSL only for a small subset of an application. On
the other hand SSL is not the "CPU killer" as sometime stated. IIS6 also support SSL
accelerators that allow to off-load the crypto operations to specialized CPUs.
IMO - in many cases it is totally OK to enable SSL protection for the whole application
which will save you from some headaches. But if you want a partitioned application,
you have to take several things into account
In the case of Forms authentication, the requireSSL attribute also checks if the user is
logging in from an SSL connection before calling FormsAuthentication.SetAuthCookie
(something you have to check yourself if you are issuing tickets manually).