Livanshi Project
Livanshi Project
PROJECT REPORT
ON
OF
By
Livanshi Gupta
(Enroll. No : 220755212005)
Singhania University
Jhunjhunu, Rajasthan
Singhania University
CERTIFICATE
This is to certify that the work entitled “Internet Tools and Web Technology ”
submitted by Livanshi Gupta in partial fulfillment for the award of the degree of
Bachelor of Computer Applications (BCA) to Singhania University, is a bonafide
record of the project work carried out under the
supervision of Mr. Sourav Bhagat
The work embodied in this report is original and has not been submitted, in
part or in full, for any other degree or diploma of this or any other university.
Candidate:
Livanshi Gupta
(220755212005)
Supervisor:
Mr. Sourav Bhagat
Singhania University
CANDIDATE’S DECLARATION
I, Livanshi Gupta, hereby declare that the work presented in this report entitled
"Internet Tools and Web Technology " is submitted in partial fulfillment of the
requirements for the award of the degree "Bachelor in Computer Application".
The report is an authentic record of our own work carried out jointly under the
supervision of Mr. Sourav Bhagat.
The matter embodied in this report has not been submitted for the award of any
other degree.
This is to certify that the above statement made by the candidate is true to the
best of our knowledge.
(Supervisor Signature)
Mr. Sourav Bhagat
Singhania University
Contents
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.
Singhania University
ASP.NET Languages structure
• Page event
• Properties & Compiler
Directives
• HTML server controls – o
Anchor o Tables o Forms o
Forms o Files
• Basic web server Controls –
o Label o Textbox o Button
o Image o Links o Check &
Radio button o Hyperlink
• Data list Web server
controls – o Check box list
o Radio button list o Drop
down list o List box, and
Data grid
o Repeater
Internet Basic:
Singhania University
The internet begin 1969, as an four computer network called ARPAnet
which was designed by the U.S. Defense Department so that research
scientists could communicate .In approximate two year, ARPAnet grew to
about twodozen sites and by 1981,consisted of more then two hundred sites
in 1990, ARPAnet was officially disbanded and the network, which now
consisted of hundred sits, came to be know as the feature .
Domain
Singhania University
computers.
""
dakota tornado
Directory
Filename
(s)htm(l) Example:
http://www.google.com
TCP/IP
TCP/IP is an abbreviation for Transmission Control Protocol/Internet Protocol.
Singhania University
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:
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
Singhania University
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>
<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
Basic
Singhania University
<body> Defines the document's body
Formatting
Singhania University
<pre> Defines preformatted text
Forms
Singhania University
<isindex> Deprecated. Defines a searchable index related to a document
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
Singhania University
<caption> Defines a table caption
<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
Singhania University
<param /> Defines a parameter for an object
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
Font styles
use the <B></B> tags to make text <B>bold</B>
Singhania University
use the <I></I> tags to make<I>italic text</I>
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.
Unordered lists
HTML-CODE EXPLANATION / EXAMPLE
NUMBERED LISTS
Plain numbers
Capital Letters
Small Letters
Singhania University
<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.
Singhania University
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.
Image Link syntax:
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:[email protected]?subject=Hello%20Sir">
Send Mail</a>
Example Program
<html><body><p>
<a href="mailto:[email protected]?subject=Hello%20sir">
Send Mail</a></p>
</body></html>
HTML Colors
Colors are displayed combining RED, GREEN, and BLUE light.
Singhania University
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
Singhania University
<caption> Defines a table caption
<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:
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2
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:
Heading Another Heading
Singhania University
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2
<th>Column 1</th>
<th>Column 2</th>
</table>
Output
<tr>
<th>Column 1</th>
</table>
Output
Singhania University
Column 1 Column 2
Row 1 Cell 1
Row 1 Cell 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%
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.
Singhania University
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
• 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">
<frameset rows="50%,50%">
<frame src="frame_a.htm">
<frameset cols="25%,75%">
<frame src="frame_b.htm">
Singhania University
<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.
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
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>
Singhania University
</head>
<body>
<p>Hello World!</p>
</body>
</html>
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');
{ background-image:url('gradient2.png'); }
Singhania University
All CSS Background Properties
Property Description Values
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
Singhania University
unicode-bidi normal
embed
bidi-override
Font Families
Example
Property Description Values
Singhania University
font-style Specifies the font style for text normal
italic
oblique
inherit
Example Program
<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
In HTML, there are two types of lists: unordered lists - the list
items are marked with bullets ordered lists - the list items
Value Description
armenian The marker is traditional Armenian numbering
decimal The marker is a number
decimal-leading-zero The marker is a number padded by initial zeros (01, 02, 03,
etc.)
georgian The marker is traditional Georgian numbering (an, ban, gan,
etc.)
lower-alpha The marker is lower-alpha (a, b, c, d, e, etc.)
lower-greek The marker is lower-greek (alpha, beta, gamma, etc.)
lower-latin The marker is lower-latin (a, b, c, d, e, etc.)
lower-roman The marker is lower-roman (i, ii, iii, iv, v, etc.)
upper-alpha The marker is upper-alpha (A, B, C, D, E, etc.)
upper-latin The marker is upper-latin (A, B, C, D, E, etc.)
upper-roman The marker is upper-roman (I, II, III, IV, V, etc.)
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 url(<URL>)
background-image
Singhania University
repeat repeat-x
repeat-y no-
background-repeat repeat
scroll
background-attachment
fixed
<percentage
> <length>
top center
background-position bottom
left right
<background-color>
<background-image>
background <background-repeat>
<background-attachment>
<background-position>
color <color>
transparent
background-color
<color>
none url(<URL>)
background-image
repeat repeat-x
repeat-y no-
background-repeat repeat
Example Program
<html><head>
<style type="text/css">
body{ background-
color:#d0e4fe;} h1
{ color:orange; text-
align:center; } p { font-
font-size:20px;
}</style></head>
<body>
<h1>CSS example!</h1>
Singhania University
<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">
div.ex { width:220px;
padding:10px;
border:5px solid
gray; margin:0px;
}
</style></head>
<body>
</body>
</html>
Example
h1.hidden {visibility:hidden;}
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>
Singhania University
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.
Singhania University
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.
Singhania University
Syntax : var <variable Name> =value
Singhania University
<html><body>
<script
type="text/javascript">
x=5+5; document.write(x);
document.write("<br />");
document.write(c);
document.write("<br />");
var oct=0377,x=10,res;
res=oct+x;
document.write(res);
x=5+"5";
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 var arrayname = new
Array(numberofelements)
<body>
Singhania University
<script type="text/javascript"> var fruits =
document.write(fruits.sort());
</script></body>
</html>
<body>
<script type="text/javascript">
function sortNumber(a, b)
{
return b - a;
"1"];
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
A set of statements are executed as a loop until a condition is satisfied, the
condition is based on an incremental or decremental counter. In other words
"Looping statements in javascript are used to execute the same set of code a
specified number of times"
If Statement
true. Syntax
if (condition)
{ code to be executed if condition
is true }
Singhania University
If...else Statement
if (condition)
{ code to be executed if condition
is true
}
else
{ c
ode
to
be
exe
cute
d if
con
ditio
n 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"); } </script>
</body> </html>
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:
Singhania University
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">
var d = new Date()
theDay=d.getDay() switch
(theDay)
{ case 1:
document.write("SUNDAY")
break; case 2:
document.write("Mon Day")
break; case 3:
document.write("Tues day")
break; default:
document.write("I'm really looking forward to this weekend!");
} </script> </body> </html>
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)
Singhania University
{ document.write("The number is "
+ i) document.write("<br>") i++
}
</script> </body> </html>
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
While loop");
} while(i!
=0)
</script>
for Loop
The for loop is used when you know in advance how many times the script
should run.
Syntax
for(var=startvalue;var<=endvalue;var=var+increment)
{ code to be
executed }
Example
Singhania University
<html> <body>
<script type="text/javascript">
+ i) 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>
<script type="text/javascript">
function myfunction(txt)
{ alert(t
xt) }
</script>
</head>
<body>
<form>
Singhania University
</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)
{ return numberA +
numberB
}
</script>
</head>
<body>
<script type="text/javascript">
document.write(total(2,5))
</script>
</body>
</html>
Dialog box
The alert() method displays an alert box with a specified message and an
OK button. Syntax alert(message)
Singhania University
Example
<html>
<head>
<script type="text/javascript">
function display()
{ alert("Hello! I am an alert
box!!");
</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()
document.getElementById("msg").innerHTML="Greetings " +
fname }
</script>
</head>
<body>
Singhania University
<input type="button" onclick="dispprompt()" value="prompt box" />
<div id="msg"></div>
</body>
</html>
Example
<html><head>
<script type="text/javascript">
function display()
continue ?")
</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
Singhania University
anchors[] Returns an array of all the anchors in the document
Anchors
document.anchors[].property
Example
<html>
<body>
<a name=" java ">java</a><br />
<a name="c++">C++</a><br />
<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
Example
<html>
<body>
<form name="Form1"></form>
<form name="Form2"></form>
<p>Number of forms:
Singhania University
<script type="text/javascript">
document.write(document.forms.length);
</script></p>
</body>
</html>
images
<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>
<a href="images.html">Images</a>
<p>Number of areas/links: <script
type="text/javascript">
document.write(document.links.lengt
h);
</script>
Singhania University
</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.
Window object
The JavaScript Window Object is the highest level JavaScript object which
corresponds to the web browser window.
Using JavaScript, we can manipulate windows in a variety of ways, such as
open one, close it, reload its page, change the attributes of the new window
etc.
Open method
The open() method opens a new browser window.
Singhania University
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>
</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>
Singhania University
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
Singhania University
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>
Singhania University
<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.
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:
Singhania University
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:
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>
Singhania University
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 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);
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
Singhania University
<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";
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
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
<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 />");
Singhania University
document.write("random"+Math.random() + "<br />");
document.write("sin"+Math.sin(3) + "<br />");
document.write("sqrt"+Math.sqrt(9) + "<br />");
</script>
</body>
</html>
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
Singhania University
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" onclick="WriteCookie();"/>
</form>
</body>
</html>
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
Singhania University
Services, or server controls gives Asp.Net the power to build real Web
application.
What is ASP.NET?
Features of ASP.NET
Singhania University
shared across Web farms, and state information can be recovered,
even if the server fails or the connection breaks down
Update files while the server is running
Components of your application can be updated while the server is
online and clients are connected. The Framework will use the new files
as soon as they are copied to the application. Removed or old files that
are still in use are kept in memory until the clients have finished.
XML-Based Configuration Files
Configuration settings in ASP.NET are stored in XML files that you can
easily read and edit. You can also easily copy these to another server,
along with the other files that comprise your application.
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.
Page During page initialization, controls on the page are available and each control's
initialization UniqueID 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.
Singhania University
Postback If the request is a postback, any event handlers are called.
event
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 @ 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
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.
Singhania University
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
need to override the Render method.
A user control (an .ascx file) automatically incorporates rendering, so you
do not need to explicitly render the control in code.
Unload This event occurs for each control and then for the page. In controls, use
this event to do final cleanup for specific controls, such as closing
controlspecific database connections.
For the page itself, use this event to do final cleanup work, such as closing
open files and database connections, or finishing up logging or other
request-specific tasks.
Note
Singhania University
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.
Singhania University
Server-side Object Tags
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.
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:
Singhania University
>>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.
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
Singhania University
Web controls
AdRotator Listbutton Image
Button DropDownList
Calendar ListBox
CheckBox Panel
RadioButton Table
HyperLink TableRow
Textbox TableCell
A sample ASP.NET Page written with Webcontrols
<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
Singhania University
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
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.
Singhania University
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.
Singhania University
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.
Singhania University
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.
Singhania University
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.
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" )
Singhania University
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>
Singhania University
<asp:Repeater>
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 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
Singhania University
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)
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
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.
Singhania University
Component classes that make up the Data Providers
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.
Singhania University
Internet Information Services (IIS) - formerly called Internet
Information Server - is a web server application and set of feature extension
modules created by Microsoft for use with Microsoft Windows. It is the world's
second most popular web server in terms of overall websites behind the industry
leader Apache HTTP Server.
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
Singhania University
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.
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
Singhania University
The following code shows how to add an attachment to an email.
Using System.IO;
Using System.Web.Mail;
mm.Attachments.Add(ma);
SmtpMail.SmtpServer="mail.programmersheaven.com";
SmtpMail.Send(mm);
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]
Form Collection
The Form collection is used to retrieve the values of form elements from a form that
uses the POST method.
Singhania University
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).
BIBLIOGRAPHY
Singhania University