Академический Документы
Профессиональный Документы
Культура Документы
UNIT – 1:
Internet Basic – Introduction to HTML – List Creating Table – Linking
document – Frames - Graphics to HTML Doc – Style sheet – style sheet basic –
Add style to document – Creating style sheet rules – Style sheet properties –
Font – Text – List – Color and Background color – Box – Display properties.
UNIT – 2:
Introduction to JavaScript – Advantage of JavaScript – JavaScript syntax
– Data type – Variable – Array – Operator and Expression – Looping
Constructor – Function – Dialog box.
UNIT – 3:
JavaScript document object model – Introduction – object in HTML –
Event Handling – Window object – Document object – Browser Object – Form
Object – Navigator object – Screen object – Build in object – User defined
object – Cookies.
UNIT – 4:
ASP.NET Languages structure – Page event, Properties & Compiler
Directives. HTML server controls – Anchor, Tables, Forms, Forms, Files. Basic
web server Controls – Label, Textbox, Button, Image, Links, Check & Radio
button, Hyperlink. Data list Web server controls – Check box list, Radio button
list, Drop down list, List box, and Data grid, Repeater.
UNIT – 5:
Request and Response Objects, Cookies, Working with Data – OLEDB
connection class, Command class transaction class, data adaptor class, data set
class. Advanced Issues – Email, Application Security – Authentication, IP
Address, Secure by SSL & Client Certificates.
Google- http://www.google.com
Info seek- http://guide.infoseek.com
Alta Vista – http://www.altavista.digital.com
Lycos – http://www.lycos.com
Yahoo! – http://www.yahoo.com
Domain
dakota tornado
Consists of 4 parts:
Directory
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 3
Filename
Example: http://www.google.com
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.
HTML
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
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 5
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
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 10
Syntax: align= [left | center | right | justify]
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>
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.
Unordered lists
NUMBERED LISTS
Plain numbers
Capital Letters
Small Letters
<ol> 1. text
<li>text</li> 2. text
<li>text</li>
</ol>
Starts a numbered list, first # being 5.
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
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.
HTML colors are defined using a hexadecimal (hex) notation for the combination
of Red, Green, and Blue color values (RGB).
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>
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>
</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>
<tr>
<th>Column 1</th>
</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
Attribute Description
rows Specifies the number of rows and their height in either pixels, percentages, or
relative lengths. Default is 100%
cols Specifies the number of columns and their width 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.
longdesc A long description - this can elaborate on a shorter description specified with the
title attribute.
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.
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 20
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">
<frame src="frame_c.htm">
</frameset>
</frameset> </html>
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.
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
CSS declarations always ends with a semicolon, and declaration groups are surrounded by
curly brackets:
<html> <head>
<style type="text/css">
P{
color:red;
text-align:center;
</style>
</head>
<body>
<p>Hello World!</p>
</body>
CSS Background
background-color
background-image
background-repeat
background-attachment
background-position
Background Color
The background-color property specifies the background color of an
element.
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');
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
unicode-bidi normal
embed
bidi-override
Font Families
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")
<html> <head>
<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 Colors
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
<html><head>
<style type="text/css">
body{
background-color:#d0e4fe;}
h1
color:orange;
text-align:center;
{
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 30
font-family:"Times New Roman";
font-size:20px;
}</style></head>
<body>
<h1>CSS example!</h1>
<p>This is a paragraph.</p>
</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">
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 31
div.ex
width:220px;
padding:10px;
margin:0px;
</style>
</head>
<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
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>
<body>
<h2>Nirvana</h2>
<h2>Radiohead</h2>
<span>Record: OK Computer</span>
<span>Year: 1997</span>
</body></html>
UNIT – 2: 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.
Syntex
<html>
<body>
<script type="text/javascript">
//your script goes here
</script>
</body>
</html>
And
<script type="text/javascript" src=‟path.js‟> </script>
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 34
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
<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";
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 37
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
}
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 39
else
{
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">
theDay=d.getDay()
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>")
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>
</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>
A confirmation dialog box is mostly used to take user's consent on any option.
It displays a dialog box with two buttons: OK and Cancel.
Syntax
confirm(message)
Example
<html><head>
<script type="text/javascript">
function display()
</body> </html>
UNIT – 3
The DOM (Document Object Model) gives you generic access to most elements,
their styles and attributes in a document.
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>
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 48
</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>
<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" />
<p>Number of images:
<script type="text/javascript">
document.write(document.images.length);
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>
<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()
{
myWindow.location.reload()
}
</script>
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 52
</head>
<body>
<input type="button" value="Open 'myWindow'" onclick="openWin()" />
<input type="button" value="Close 'myWindow'" onclick="closeWin()" />
<input type="button" value="Reload" onclick="Relo()" />
</body>
</html>
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.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
Property Description
availHeight Returns the height of the screen (excluding the Windows
Taskbar)
Screen Syntax
screen.availHeight
screen.availWidth
screen.colorDepth
screen.height
screen.pixelDepth
screen.width
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.
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 55
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.
action:
This property is a read or write property and its value is a string.
elements[]:
It contains all fields and controls present in the form. The user can access any
element associated with the form by using the looping concept on the elements
array.
encoding:
This property is a read or write property and its value is a string. This property
helps determine the way of encoding the form data.
length:
This denotes the length of the elements array associated with the form.
method:
This property is a read or write property and its value is a string. This property
helps determine the method by which the form is submitted.
name:
name property of form object denotes the form name.
target:
This property denotes the name of the target window to which form it is to be
submitted into.
button:
The button property of form object denotes the button GUI control placed in the
form.
checkbox:
checkbox property of form object denotes the checkbox field placed in the form.
select:
select property of form object denotes the selection list object placed in the
form.
submit:
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 56
submit property of form object denotes the submit button field that is placed in
the form.
text:
text property of form object denotes the text field placed in the form.
textarea:
textarea property of form object denotes the text area field placed in the form.
<HTML>
<HEAD>
<TITLE>Test Input</TITLE>
</HEAD>
<BODY>
<FORM NAME="myform" ACTION="" METHOD="GET">Enter box: <BR>
<INPUT TYPE="text" NAME="inputbox" VALUE=""><P>
<INPUT TYPE="button" NAME="button" Value="Click" >
<br>
Genter
<INPUT TYPE="radio" NAME="rad" VALUE="radio_button3" onClick=0>
<INPUT TYPE="radio" NAME="rad" VALUE="radio_button4" onClick=0>
<br>Language know<br>
<INPUT TYPE="checkbox" NAME="check2" Value="Check2">Tamil<BR>
<INPUT TYPE="checkbox" NAME="check3" Value="Check3">English<BR>
</br>
This is Text Area
<TEXTAREA NAME="myarea" COLS="40" ROWS="5">
</TEXTAREA>
</br>
List Items
<SELECT NAME="list" SIZE="1">
<OPTION>This is item 1
<OPTION>This is item 2
</SELECT>
</br>
<FORM>
<INPUT TYPE="file" NAME="elementName">
</FORM>
</FORM>
</BODY>
</HTML>
Built-in objects
These built-in objects are available through both the client-side JavaScript and
through LiveWire (Netscape's server-side application).
The three built-in objects are: the String object, the Math object, and
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 57
the Date object. Each of these provides great functionality, and together they
give JavaScript its power as a scripting language.
The String Object
The String object is used to manipulate a stored piece of text.
String objects are created with new String().
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>
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 58
<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";
var patt1=/ain/gi;
document.write(str1.match(patt1)+ "<br />");
document.write(str.replace("Microsoft", "W3Schools"));
document.write(str.search("W3SCHOOLS"));
document.write(str.substr(3)+"<br />");
document.write(str.substr(3,4));
</script>
</body>
</html>
Date Object
Method Description
Example
<html>
<body>
<script type="text/javascript">
var d=new Date()
document.write(d.getDate())
document.write(".")
document.write(d.getMonth() +1)
document.write(".")
document.write(d.getFullYear())
document.write(".")
document.write(d.getHours())
</script>
</body>
</html>
Math Object
Syntax
var x = Math.PI; // Returns PI
var y = Math.sqrt(16); // Returns the square root of 16
Property Description
Example
All user-defined objects and built-in objects are descendants of an object called
Object. .
The new Operator:
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
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 62
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>
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 63
<body>
<form name="myform" action="">
Enter name: <input type="text" name="customer"/>
<input type="button" value="Set Cookie" onclick="WriteCookie();"/>
</form>
</body>
</html>
Microsoft. NET
The Microsoft. NET strategy was presented by Microsoft officials to the rest of the world in June 2000:
NET Framework
The .NET Framework is the infrastructure for the new Microsoft .NET Platform.
The .NET Framework is a common environment for building, deploying, and running Web Services and Web
Applications.
The .NET Framework contains common class libraries - like ADO.NET, ASP.NET and Windows Forms - to
provide advanced standard services that can be integrated into a variety of computer systems.
The .NET Framework is language neutral. Currently it supports C++, C#, Visual Basic, JScript (The Microsoft
version of JavaScript) and COBOL. Third-party languages - like Eiffel, Perl, Python, Smalltalk, and others -
will also be available for building future .NET Framework applications.
The new Visual Studio.NET is a common development environment for the new .NET Framework. It
provides a feature-rich application execution environment, simplified development and easy integration
between a number of different development languages.
The runtime automatically handles object layout and manages references to objects, releasing them when they
are no longer being used. Objects whose lifetimes are managed in this way are called managed data. Garbage
collection eliminates memory leaks as well as some other common programming errors. If your code is
managed, you can use managed data, unmanaged data, or both managed and unmanaged data in your .NET
Framework application. Because language compilers supply their own types, such as primitive types, you
might not always know (or need to know) whether your data is being managed.
The common language runtime makes it easy to design components and applications whose objects interact
across languages. Objects written in different languages can communicate with each other, and their
behaviors can be tightly integrated. For example, you can define a class and then use a different language to
derive a class from your original class or call a method on the original class. You can also pass an instance of a
class to a method of a class written in a different language. This cross-language integration is possible because
language compilers and tools that target the runtime use a common type system defined by the runtime, and
they follow the runtime's rules for defining new types, as well as for creating, using, persisting, and binding
to types.
As part of their metadata, all managed components carry information about the components and resources
they were built against. The runtime uses this information to ensure that your component or application has
the specified versions of everything it needs, which makes your code less likely to break because of some
unmet dependency. Registration information and state data are no longer stored in the registry where they
can be difficult to establish and maintain. Rather, information about the types you define (and their
dependencies) is stored with the code as metadata, making the tasks of component replication and removal
much less complicated.
Language compilers and tools expose the runtime's functionality in ways that are intended to be useful and
intuitive to developers. This means that some features of the runtime might be more noticeable in one
environment than in another. How you experience the runtime depends on which language compilers or
tools you use. For example, if you are a Visual Basic developer, you might notice that with the common
language runtime, the Visual Basic language has more object-oriented features than before. Following are
some benefits of the runtime:
Performance improvements.
The ability to easily use components developed in other languages.
Extensible types provided by a class library.
New language features such as inheritance, interfaces, and overloading for object-oriented
programming; support for explicit free threading that allows creation of multithreaded, scalable
applications; support for structured exception handling and custom attributes.
If you use Microsoft Visual C++.NET, you can write managed code using the Managed Extensions for C++,
which provide the benefits of a managed execution environment as well as access to powerful capabilities
and expressive data types that you are familiar with. Additional runtime features include:
Common Type System (CTS) describes how types are declared, used and managed in the runtime and
facilitates cross-language integration, type safety, and high performance code execution.
The CLS is simply a specification that defines the rules to support language integration in such a way that
programs written in any language, yet can interoperate with one another, taking full advantage of
inheritance, polymorphism, exceptions, and other features.
ASP.NET
ASP.NET is the latest version of ASP. It includes Web Services to link applications, services and devices using
HTTP, HTML, XML and SOAP.
New in ASP.NET:
Asp.Net – Introduction
Asp.net is the new offering for Web developers form the Microsoft. It is not simply the next generation of
ASP. Because it has evolved from Asp, Asp.Net looks very similar to its predecessor. But concepts like web
forms, Web Services, or server controls gives Asp.Net the power to build real Web application.
ASP.NET provides services to allow the creation, deployment, and execution of Web Applications
and Web Services
Like ASP, ASP.NET is a server-side technology
Web Applications are built using Web Forms. 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 Forms are designed to make building web-based applications as easy as building Visual Basic
applications
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
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.
Page During page initialization, controls on the page are available and each control's UniqueID
initialization property is set. Any themes are also applied to the page. If the current request is a postback,
the postback data has not yet been loaded and control property values have not been
restored to the values from view state.
Load During load, if the current request is a postback, control properties are loaded with
information recovered from view state and control state.
Validation During validation, the Validate method of all validator controls is called, which sets the
IsValid property of individual validator controls and of the page.
Postback event If the request is a postback, any event handlers are called.
handling
Rendering Before rendering, view state is saved for the page and all controls. During the rendering
phase, the page calls the Render method for each control, providing a text writer that writes
its output to the OutputStream of the page's Response property.
Unload Unload is called after the page has been fully rendered, sent to the client, and is ready to be
discarded. At this point, page properties such as Response and Request are unloaded and
any cleanup is performed.
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 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
If the request is a postback, the values of the controls have not yet been restored from
view state. If you set a control property at this stage, its value might be overwritten in
the next event.
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
In a postback request, if the page contains validator controls, check the IsValid
property of the Page and of individual validation controls before performing any
processing.
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.
There are two different kinds of custom controls. On the one hand there are the controls that ship with .NET,
and on the other hand you can create your own custom controls. Using custom server controls is the best way
to encapsulate common programmatic functionality.Just specify elements as you did with HTML elements,
but add a tag prefix, which is an alias for the fully qualified namespace of the control. Again you must
include the runat=server attribute. If you want to get programmatic access to the control, just add an Id
attribute.You can include properties for each server control to characterize its behavior. For example, you can
set the maximum length of a TextBox. Those properties might have sub properties; you know this principle
from HTML. Now you have the ability to specify, for example, the size and type of the font you use .The last
attribute is dedicated to event binding. This can be used to bind the control to a specific event
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.
At the bottom of the Architecture is Common Language Runtime. NET framework common language
runtime resides on top of the operating system services. The common language runtime loads and executes
code that targets the runtime. This code is therefore called managed code. The runtime gives you, for
example, the ability for cross-language integration.
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.
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 73
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.
Asp.Net – Controls
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
<html>
<body>
<form runat="Server">
</form>
</body>
</html>
– 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
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
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 76
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>
<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.
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.
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 79
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.
The DataGrid control displays the fields of a data source as columns in a table. Each row in
the DataGrid control represents a record in the data source. The DataGrid control supports
selection, editing, deleting, paging, and sorting.
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.
Example
<Script Runat="Server">
Sub Page_Load
conNorthwind.Open()
dgrdEmployees.DataSource = cmdSelect.ExecuteReader()
dgrdEmployees.DataBind()
conNorthwind.Close()
End Sub
</Script>
<html><head><title>ExpertDataGrid.aspx</title></head>
Repeater control
Use the Repeater control to create a basic templated data-bound list. The Repeater control
has no built-in layout or styles; you must explicitly declare all HTML layout, formatting, and
style tags within the control's templates.
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.
<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>
UNIT – 5:
Cookies Overview
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
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:
Visual Basic
Response.Cookies("userName").Value = "patrick"
Response.Cookies("userName").Expires = DateTime.Now.AddDays(1)
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
The dataset is a disconnected, in-memory representation of data. It can be considered as a local copy of the
relevant portions of the database. The DataSet is persisted in memory and the data in it can be manipulated
and updated independent of the database. When the use of this DataSet is finished, changes can be made
back to the central database for updating. The data in DataSet can be loaded from any valid data source like
Microsoft SQL server database, an Oracle database or from a Microsoft Access database.
Data Provider
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.
The Command object is represented by two corresponding classes: SqlCommand and OleDbCommand.
Command objects are used to execute commands to a database across a data connection. The Command
objects can be used to execute stored procedures on the database, SQL commands, or return complete tables
directly. Command objects provide three methods that are used to execute commands on 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:
HTTP modules - Used to perform tasks specific to HTTP in the request-processing pipeline, such as
responding to information and inquiries sent in client headers, returning HTTP errors, and redirecting
requests.
Security modules - Used to perform tasks related to security in the request-processing pipeline, such as
specifying authentication schemes, performing URL authorization, and filtering requests.
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 87
Content modules - Used to perform tasks related to content in the request-processing pipeline, such as
processing requests for static files, returning a default page when a client does not specify a resource in a
request, and listing the contents of a directory.
Compression modules - Used to perform tasks related to compression in the request-processing pipeline,
such as compressing responses, applying Gzip compression transfer coding to responses, and performing
pre-compression of static content.
Caching modules - Used to perform tasks related to caching in the request-processing pipeline, such as
storing processed information in memory on the server and using cached content in subsequent requests
for the same resource.
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.
Sending Email
Using System.IO;
Using System.Web.Mail;
Created by K.Dharmarajan M.Sc, M.Phil., Asst Professsor ,Vels University, Chennai-117 88
MailAttachment ma=new MailAttachment("c:\sample.txt");
MailMessage mm=new MailMessage();
mm.To ="xyz@programmersheaven.com";
mm.From="abc@yahoo.com";
mm.Body ="Attachment";
mm.Subject="Check out the attached text file";
mm.Attachments.Add(ma);
SmtpMail.SmtpServer="mail.programmersheaven.com";
SmtpMail.Send(mm);