ASP.NET
A revolution in the web programming world
Covers Concepts Programs
Authored by
B.KANNA BABU
Acknowledgements
I want to acknowledge my deep gratitude to
Mr.T.S.S.sunil Kumar and Mr.G.Sudhakar who
encouraged me a lot for their cooperation
Iam also thankful to Mr.Ganesh, Mr.satyanarayna
Mr.Thandava Krishna, Mr.Manik basava, Mr. Joji babu
who has provided staunch support throughout the
project and helped me to complete this book successfully
Some errors may have inadvertently crept in this
book. despite my best efforts to keep them out. Readers
are therefore encouraged to point out these errors so
that they are not repeated in the next
edition.suggesitions to improve the book are also
welcome.mail me at [email protected]
About the Author
Mr.B.kanna Babu has been associated
with teaching Microsoft Technologies
As a corporate trainer for a couple of
organizations. he worked at various
colleges as professor and he has
participated in many technical paper
presentations
CONTENTS
1. Introduction To MS.net
1.1 Microsoft Development technology 1.2 Versions Of Ms.net
1.3 Features according to versions of .net 1.4 MS.net Framework 1.4.1 MS.net framework 1.4.2 Microsoft Products 1.4.3 MS.net Services 1.4.4 MS.net Servers 1.4.5 MS.net Tools 1.4.6 MS.net Languages 1.4.7 MS.net Technologies 1.5 MS.net Architecture 1.5.1 Application layer 1.5.2 Base class Layer 1.5.3 Translating layer 1.6 Intermediate Language 1.6.1Metadata 1.6.2 Code 1.6.3 Resource 1.6.4 Manifest
1.7 Common Language runtime 1.7.1 IL Loader 1.7.2 Access Controller 1.7.2.1 CTS 1.7.2.2 CLS 1.7.2.3 CAS 1.7.2.4 RBS
1.7.2.6.1 Pre JIT
1.7.2.6.2 Standard JIT 1.7.2.6.3 Echno JIT
2. Hyper Text Markup Language
2.1 Features Of HTML 2.2 Tag References
2.2.1 Basic Tag 2.2.2 Link Tag
2.2.3 Text Formatting Tag 2.2.4 List Tags 2.2.5 Multimedia Tag 2.2.6 Font Tag 2.2.7 Frame Tag I. Form Tag 2.3 Button controls 3 Scripting Languages
3.1 Different Types of Scripting languages 3.2 Features Of scripting Languages
4 JavaScript
4.1 Variables in JavaScript 4.2 Functions in Javascript 4.3 Working with JavaScript 4.4 JavaScript Object hierarchy 4.5 Objects in JavaScript
5 Dynamic Hypertext Markup Language
5.1 Cascading style sheets 5.1.1 Types Of CSS
5.1.1.1 Inline style sheet
5.1.1.2 Embedded style sheet 5.1.1.2.1 tag as selector 5.1.1.2.2 class as selector 5.1.1.2.3 ID as selector 5.1.1.3 External style sheet
5.1.1.4 Imported style sheet
6 ASP.NET
6.1 Why ASP.net
6.2 Evolution of ASP.net 6.3 Features of ASP.net
7 Internet information service(IIS) 8 Working with ASP.net Applications
8.1 Why ASP.net
8.2 Evolution of ASP.net 8.3 Features of ASP.net
8.4 Difference between ASP and ASP.net
9 Coding Techniques in ASP.net
9.1 Code inline model 9.2 Code behind model
10 Controls in ASP.net
10.1 client side controls 10.2 silverside controls
10.2.1 HTML server controls 10.2.2 Web server controls
10.2.3 Common properties with webserver controls 10.3 Different Types of controls in ASP.net
10.3.1 Standard controls and examples 10.3.1.1 Label
10.3.1.2 TextBox with Example 10.3.1.3 CheckBox with Example 10.3.2 Redirecting The user Request
10.3.2.1 Hyperlink Button with Example 10.3.2.2 Link Button with Example 10.3.2.3 Image Button with Example 10.3.2.4 Differences b/n button controls 10.3.2.5 Response. Redirect
10.3.2.6 Server. Transfer 10.3.3 Button controls
10.3.3.1 Events with Button Controls 10.3.3.2 Click Event with Example
10.3.3.3 Command Event with Example 10.3.4 Listing Controls 10.3.4.1 ListBox 10.3.4.2 DropDownList 10.3.4.3 RadioButtonList 10.3.4.4 CheckBoxList 10.3.4.5 Panel control 11 Validation Controls
11.1 Difference b/n client side and server side validation 11.2 Different Types of validation controls
11.2.1 Required Field validator with Example 11.2.2 Range validator with Example
11.2.3 Regular Expression Validator with Example 11.2.4 Compare validator with Example
12 Navigation Controls
12.1 Menu Controls with Example 12.2 Treeview Controls with Example
13 Calendar control with example 14 ADO.net 14.1 introduction to ADO.net 14.1.1 I-layered approach 14.1.2 II-layered approach 14.1.3 III-layered approach 14.2 ADO vs ADO.net
14.3 ADO.net architecture diagram 14.4 Connection oriented architecture
14.4.1 Data Providers in ADO.net 14.4.2 Objects in ADO.net
14.4.3 Steps to work with connection architecture 14.4.4 Example with Connection object
14.4.5 Command object
14.4.6 Steps to work with command object 14.4.7 Differences between Execute methods 14.4.8 Example with command object to delete . 14.4.9 Example with insert, update and delete 14.4.10 disadvantages with connection oriented. 14.5 Disconnected Architecture
14.5.1 Disconnected Data cycle 14.5.2 Dataset
14.5.2.1 Steps to work with Dataset 14.6 Data Bound Controls
14.6.1 Templates
14.6.2 Types Of Data Bound Controls 14.6.2.1 Repeater Control 14.6.2.2 Data list Control 14.6.2.3 Grid view Control 14.7 Repeater Control
14.7.1 Designing Repeater Control in Table 14.8 Data List Control
14.8.1 Events associated with Data List Control 14.8.2 Displaying Data in Datalist Control
14.8.3 Deleting with Data List Control 14.8.4 Editing with Data List Control 14.9 Grid View Controls
14.9.1 Displaying Data in GridView 14.9.2 Paging with GridView
15 Ad Rotator Control 16 CSS in ASP.net 17 Themes and Skins 18 Master Pages
19 State Management in ASP.net
15.1 View state 15.2 URL encoding 15.3 Cookies 15.4 Sessions 15.5 Application 15.6 Caching 15.7 Query String
20 500 Frequently asked questions
Integrated one environment which enables to communicate device to device or application to application.
It provides one environment for developing different applications rapidly and efficiently.
MICROSOFT DEVELOPMENT TECHNOLOGY
• OLE TECHNOLOGY: it is used for multiple application access by creating link between the application
• COM TECHNOLOGY: it is used to create the communication between the modules
• MS.NET: later they upgraded these technologies in new environment called as MS.NET
VERSIONS OF .NET:
MS.NET 1.0:-introduced in the year 2000 (beta) MS.NET 1.0:-introduced in the year 2002 (alpha) MS.NET 1.1:-introduced in the year 2003 (alpha) MS.NET 2.0:-introduced in the year 2004 (beta ) MS.NET 2.0:-introduced in the year 2005 (alpha) MS.NET 3.0
MS.NET 3.5
Note: Microsoft has given a statement that some new frameworks are Released under winfx named later renamed as Microsoft.net3.0
Features according to versions of .net:
MS.net1.0 many application support Separate installation
Crystal report installation Mobile application
MS.net1.1 Crystal report and Mobile application are inbuilt
MS.net2.0 64-bit compatibility
Along SQLserver Enterprise edition Generic Classes,Generic methods, nullable types etc…
.NET FRAMEWORK It is the layer between Application and OS It consists of 1. CLR 2. BCL Tools:compiler Interpreter Debugger Assembler and disassembler .NET PRODUCTS MSVisual studio editor MS Simulator .NET Servers • MSSQL Server • BizTalk server • IIS • Mobile IIS • Exchange server • Internet Security Server Etc…….. .NET Services • Passport service • Calendar service • Contact Service • Alert Service • Web service Etc…. MICROSOFT.NET
1).NET FRAMEWORK : it protects the OS and enables the application
execution
CLR: it is the runtime environment used to execute all the .net
applications.
It applies security, memory management and monitors the execution of
the program.
Base Class Libraries: it provides some predefined functionality which can
be reused for developing the application in .net environment. Nearly 4000 predefined Classes are provided for developing the applications
2) MICROSOFT PRODUCTS : MS has provided its products for faster
development
Of applications and testing of the applications a. MS VISUAL STUDIO EDITOR
for developing different types of applications i.e. execution, debugging, designing etc
POCKET PC SIMULATOR: it is a special type of environment used for
testing mobiles and smart pc applications
3) .NET SERVICES: a service is a back roundly running program which is
used for automatic the process
Ex: passport, alert, contact, address, web service, calendar etc…..
4) .NET SERVERS: MS has provided nearly 14 servers support like a). IIS :which acts as the webserver for ASP.net web application b).MOBILE IIS: which acts as a webserver for mobile application
c).MS SQLSERVER:it acts as a database for storing information
permanently
d).ISS: Internet security server it is used for applying security for ASP.net
applications
e).BISTALK SERVER: it is used to store the information in XML format f).EXCHANGE SERVER: it is used for exchanging mails
g).ECOMMERCE: it is used for online banking etc….
5).NET TOOLS: it is used for compiling and executing or checking the
structure of files by using built-in tools like
Compilers,interpreters,debuggers,assemblers,disassemblers etc…
6).NET LANGUAGES: it supports different types of languages to group all
the programmers in the world and works under one platform called MS.NET .NET1.0 supports 17 languages
.NET1.1 supports 21 languages .NET2.0 supports 32 languages
Ex: MICROSOFT LANGUAGES
VB.NET C#.NET
VISUAL C++.NET VISUALJ#.NET
THIRD PARTY LANGUAGES
COBOL.NET PASCAL.NET EFFIEL.NET MANAGED C++.NET JSCRIPT.NET PERL.NET PYTHON.NET etc….
7).NET TECHNOLOGIES: a technology is the convergence of more than one
ADO.NET is used for database handling
WEBSERVICES are used for complete distributed applications
ARCHITECTURE OF MS.net Application layer Translating layer Base class layer C#.net Web applicat Vb.net J#.net Windows
applicat Mobile webapplicat applicatService
Data IO Security XML Threading Memory management CLR Security checking Monitoring The Life cycle OS
ARCHITECTURE OF MS.NET
APPLICATION LAYER: This layer is used for presenting the
application by developing the front ends. This layer provides some collection of languages and application from which we can choose and develop the application
BASECLASSLIBRARIES: This layer provides some predefined
functionalities which are used by application layer for developing the application
TRANSLATING LAYER : This layer is used to convert your application to OS
understandable language by managing the memory, checking the security and monitoring the program
.net application----compilation----IL---CLR---OS
IL (intermediate language): it is the compiled format of any .net program which is OS independent. It can be called as MSIL, CIL, and assembly IL format is of two types .dll format: it is reusable format it is not executable format .exe format: it is executable format it is not reusable ILARCHETECTURE:it consists of 4 parts and 1 wrapper to describe itself METADATA CODE RESOURCE MANIFEST PE WRAPPER
METADATA: it is used to describe the data of the IL file i.e. it provides the
structure of the program like class names, method names etc…
CODE: it provides the actual instructions of IL file
RESOURCE: it provides the additional information like images, cursors, icons et MANIFEST: it provides documentary information like product name, company
name, and version no, strong name etc….
ILDASM.exe: it is a build-in tool of .net used to show the wrapper file or IL file
CLR
ILLOADER ACCESS CONTROLER CAS RBS CTS CLS MEMORY MANAGEMENT JIT COMPILER• CLR is common language runtime
• It is a runtime environment used to convert IL file to native OS understandable format and also provides some services like memory management, type checking, monitoring the lifecycle of the program etc…
• It is the heart and soul of .net frame work used to perform every operation in .net • It consists of • IL loader • Access controllers • Memory management • Jit compiler
• IL LOADER: it is used to load the complete IL file in to the clr.
• Access Controller : it is used to check the security privileges of IL file
languages and checks whether IL file is using those data types are not 2. CLS: common language specification: it provides some common rules
for all .net languages and check whether IL file is following those rules are not
3. CAS:code access security: it checks whether the code is executing on
the O.S and if it is invalid code it displays error message
4. RBS : role based security: it checks whether the login user is valid or
invalid and it provides permissions for accessing and executing .net applications. by default administrator have the privileges for accessing .net applications
• Memory management: it look after the memory allocation and
memory
Deal location .it uses GIGO process for memory management.
Note: Managed applications: the applications whose memory management will look after by runtime environment i.e. by CLR
Without any user interface is called managed application.
JIT compiler: it is used for converting IL code in to native machine
understandable format by compiling it
Types of compilers:
• PreJIT : it is used to convert the complete IL code into native machine
understandable format
• Standard JIT: it is used to convert only the called method to machine
understandable format use it and remove it from the memory
• Echno JIT : it is used to convert the called method to machine
understandable format use it and maintain the copy in the temporary location for the next request
Web applications
Dev WebPages Static webpage Dynamic webpage HTML PHOTOSHOP FLASH client side Server side DHTML ASP ASP.NET ISP SERVELETS• Static webpage: a webpage whose output is static with diff request is called as static webpage which can be generated by using HTML,PHOTOSHOP,FLASH.
• Dynamic webpage: a webpage which provides different outputs for diff clients request is called dynamic webpage.
• Client side dynamic webpage: a webpage whose o/p changes with every request to provide new look and animated affects which can be generated by DHTML concepts
by some technologies like ASP, ASP.NET, JSP, SERVELETS etc….
HTML: Hyper text markup language
It is used for dev static WebPages and it is one of the markup language
Markup language: a language which is used for concentrating on the structure and formatting of the document to display.
SML: specific markup language: a markup language which is specific for an
application or OS which is not compatible with other application or OS
• Ex:RTF,HTML
• GML:Generalised markup language: it is used to provide generalized
format which can be understand by any device or os
• Ex:XML
• Features of HTML:
• It is free form language (case insensitive language) • It is space insensitive language
• It is line insensitive language • It is error free language • It is tag oriented language
• Tag is a command enclosed in angular braces
Syn :<cmd>
Tag contains two elements starting element and ending element Starting element <command>
Ending element </command>
• Tags are of two types container tags and non container tags
• The tag which contains both starting element and ending elements is called container tags
Ex: <html>……… </html> <p>………</p>etc….
• Tags which provides only starting elements are called non container tags
Ex :<br>break line
<hr>horizontal ruler etc………
TAG REFERENCES
Different types of tag references are
1. BASIC TAG
2. TEXT FORMATING TAG 3. LINK TAG 4. LIST TAG 5. FRAME TAG 6. TABLE TAG 7. FORM TAG 8. MULTIMEDIA TAG
Basic tags: these tags will provide the structure of the document Ex:
<html> <head>
<body bgcolor="#CCCCCC" background="F:\WALLPAPERS\Ganesh.jpg">
THIS IS HTML DOCUMENT THIS IS MY FIRST PROGRAM </body>
</html>
Link tag: it is used for linking one document with another document Or different parts of same document
• Hyper link: it is used for linking two documents
h1
F1.html
F2.html
link
• Cross link: it is used for linking same document different paths • Anchor tag is used for linking
Ex for hyper link <html>
<head>
<title>HELLO</title> WELCOME TO HTML </head>
<body bgcolor="cyan" background="F:\WALLPAPERS\All Pictures\14.jpg" >
THIS IS HTML DOCUMENT
<a href="E:\TECHNOLOGIES\6pm\HTML\basictag.html"> click here to show basic tag
</a>
</body></html>
• Text formatting tags : these tags are used to formatting the text by
applying font style, size and font names etc…
Ex:
<B> BOLD <I> ITALIC
<U> UNDERLINE <SMALL> SMALL FONT <BIG> Big FONT <STRONG> <S><SUP><SUB> <FONT> <HR><BR><P> <PRE> LIST TAGS:
It is used to display the information in bulleted format or numbered format etc……..
<ul> unordered list <ol >ordered list <li >list item
<dd>data definition <dl>data list
<dt >data table Ex for List tags
source code: <Html> <h1> MEMORY <UL TYPE="SQUARE"> <LI>PRIMARY MEMORY <OL TYPE="1"> <LI>RAM <LI>ROM </OL> <LI>SECONDARY MEMORY <OL TYPE="I"> <LI>HARD DISC <LI>COMPACT DISC </OL> </UL> </H1> </html>
MULTIMEDIA TAGS: this tag is used to display the images on the text
• <IMG>TAG:<IMG SRC=“PATH OF IMAGE” DYNSRC=“PATH OF
<MARQUEE>
<H1> WELCOME</H1> </MARQUEE>
• <MARQUEE> IT IS USED TO PROVIDE SOME ANIMATION AFFECTS • PROPERTIES:
• <MARQUEE DIRECTION= “RIGHT” “LEFT” “UP” “DOWN” BEHAVIOUR=“ALTERNATE” “SCROLL” LOOP=“SOME NO”
SCROLL AMOUNT=MILLISEC SCROLLDELAY=MILLISEC BG COLOR=“SOME COLOR”
WIDTH=SOMENO HT=SOME NO BORDER=SOME NO>
Source code: <HTML>
<IMG SRC="D:\KANNA PICS\SP_A0101.jpg" WIDTH=200HT=50 BORDER=5>
<MARQUEE DIRECTION="left" BEHAVIOUR="alternate" LOOP="-1" SCROLLAMOUNT=100 SCROLLDELAY=1000 BGCOLOR="RED"> <H1>WELCOME</H1>
</MARQUEE> </HTML>
Font tags:
Syn :<font face=“value” size=“value” color=“value”> </font>
• Font tags: Syn : <font face=“value” size=“value” color=“value”> </font> Arial Monotype Corsiva Times New Roman 1 least size 2 3 default size 4 5 6 7 highest size
Example with font tags
View source <Html>
HI KANNABABU </FONT>
<BR><BR><BR>
<FONT FACE="TAHONA" SIZE="7" COLOR="BLUE"> HTML IS MARKUP LANGUAGE
<BR><BR><BR>
<FONT FACE="VERDANA" SIZE="5" COLOR="GREEN"> HTML SUPPORTS FONT TAGS
</FONT> </body> </html>
FRAME TAGS:
These tags are used to divide the webpage into different webpartsFrameset tags has two optional attributes
ROWS ATTRIBUTES: it is used to divide the webpage in to horizontal parts COLUMNS ATTRIBUTE: it is used to divide the webpage into vertical parts
• Each part of the webpage is known as a frame
• Every frame should be identified using “NAME” attribute
• To assign the name to a frame frameset tag contains a sub tag known as frame
• It is a note after displaying webpage
• There is no direct method to display the contents within a frame directly • any matter we want to display within aframe we will store in a html file and • attach this HTML file to the frame using src attribute
• Frame names are case sensitive
View source:
<? Code for frame.html...> <HTML>
<FRAMESET ROWS="30%,70%">
<FRAME NAME="a" src="kanna.html"> <FRAMESET cols="25%, 75%">
<FRAME NAME="b" src="link.html"> <FRAME NAME="c" src="home.html"> </FRAMESET>
</FRAMESET> </HTML>
Form Tags:
<Form> Properties: method=get\post name=some text action=some path <input type=text> Name=some path Value=number Read-only Disabled
Textbox is the data entry control
Password textbox:it is used to accept some text but hides the text with some symbol like *
Properties are same as textbox
Multiline textbox: it is used for accepting multiple lines of text <text area>
Name=some text Value=some text Rows=some no Columns=some no
Note: text area tag is noncontainer tag
Radio button control: this control is used for providing a group of options
from which we can select anyone.
Syn: <input type=radio name=some text>
Checkbox control: it is used for selecting and deselecting an item
Syn: <input type=checkbox name=some text>
Dropdown list :it is used for providing some list of items from which we
can select any one in a dropdown fashion. Syn: <select name=“some text”> <option selected>……….. ……… ……… </select>
Listing Controls: it provides list of items in a box format from which we can
select single or multiple items by holding control key Syn: <select name=“some text” size=no multiple> <option selected>………..
……… ……… </select>
View source: <HTML> <HEAD> <H1 ALIGN="CENTER">KANNA TECHNOLOGIES </H1> <H2 ALIGN="CENTER"> HYDERABAD </H2> </HEAD> <HR COLOR="BLUE"> <BODY>
<B><U> <FONT SIZE="4" COLOR="RED"> PERSONAL DETAILS FORM </FONT></U></B> <FORM NAME="F1"
action="" method=get> <table align="center"> <tr>
<td>ENTER YOUR NAME : </td>
<td><INPUT TYPE="TEXT" NAME="T1"></td> </tr>
<tr>
<td>ENTER USER NAME :</td>
<td><INPUT TYPE="TEXT" NAME="T2"></td> </tr><tr>
<td>ENTER PASSWORD :</td>
<td><INPUT TYPE="PASSWORD" NAME="T3"></td> <tr><BR><tr>
<td><INPUT TYPE="RADIO"
NAME="GENDER" VALUE="MALE">MALE <INPUT TYPE="RADIO" NAME="GENDER" VALUE="FEMALE"> FEMALE </td><BR> </tr><tr> <td>SELECT QUALIFICATION </td> <td><SELECT NAME="CB1"> <OPTION> SSC </OPTION> <OPTION> 10+2 </OPTION> <OPTION> DEGREE</OPTION> <OPTION> PG </OPTION> <OPTION> OTHERS </OPTION> </SELECT></td>
</tr>
<BR><tr><td>SELECT HOBBIES :</td><nbsp>
<td><INPUT TYPE="CHECKBOX" NAME="C1" VALUE="DANCING"> DANCING <INPUT TYPE="CHECKBOX" NAME="C2" VALUE="PLAYING"> PLAYING
<INPUT TYPE="CHECKBOX" NAME="C3" VALUE="BROWSING"> BROWSING
<INPUT TYPE="CHECKBOX" NAME="C4" VALUE="CHATTING"> CHATTING </td></tr>
<tr><td>DESCRIBE YOUR SELF :</td>
<td> <TEXTAREA NAME="TA1" ROWS="5" COLS="10"> </TEXTAREA> </td> </tr><BR><tr><td><INPUT TYPE="SUBMIT" NAME="B1"
VALUE="SUBMIT"></td>
<td><INPUT TYPE="RESET" NAME="B2" VALUE="RESET"></td></tr>
</FORM> </BODY> </HTML>
BUTTON CONTROLS
• RESET BUTTON: it is used for providing a webpage with default settings
path mentioned in the action attribute of form tag Syn :<input type=“submit” value=“submit”>
• Reset Button: this tag is used for invoking some functions of scripting languages
Syn :<input type=“button” value=“click”>
SCRIPTING LANGUAGES:
• These are the interpreted languages where the execution is on the client machine
• Different types of scripting languages
• ECMA:Europeon computer manufacturer association develop first scripting language for computer manufacturer architecture
• LIVE SCRIPT: which was later renamed as JavaScript? it is product of sun Microsystems
• Vb script: it is developed by Microsoft for macro programming in MS office package
• Jscript:it is product of Microsoft resembles JavaScript • Pearl script
• Python script
• Anaconda script etc….
• Features of scripting languages : these are used for providing client
side calculations • Provides animations
• Supports validations by accepting proper input from the user
• It also enables for database and file handling by depending on com components
Java script
• JavaScript is the premier client-side scripting language used today on the Web.
• JavaScript can be used to manipulate the very markup in the documents in which it is contained.
• It is client side scripting programming language
• Java script code can be written in any text editor
• JavaScript code can be executed in any browser
• It is case sensitive programming language
• To execute JavaScript code browser contains scripting language parser
• Parser is similar to interpreter
• It is platform independent
• JavaScript code is written in between <script >……</script>tag
• Java script code is developed by Netscape company
• Java script is object based programming language
• Java script does not contain any predefined data types
• HTML tags can be integrated within the JavaScript code
• To add JavaScript to your webpage place the tag
<script language=“JavaScript’> Ex:
<html>
<script Language=“JavaScript’> Document. Write (“welcome”) </script>
</html>
VARIBLES IN JAVASCRIPT
• JavaScript doesn’t support any predefined data types that’s why JavaScript is known as loosely typed programming language
• To declare variable in JavaScript we use 2 methods • Variable=value
• Var variable=value
Ex:
S=“welcome” var s=“welcome”
S=10 var s=10
S=10.5 var s=10.5
S is global variable s is local variable
• Variable names are case sensitive
• There is no limit for data to store in a variable we can store up to 32 bytes any amount of data
Working with variables <Html>
<script Language=“JavaScript’>
S=“<h1>WELCOME</h1>” ‘or’ s=“welcome” document.write(“s”) document.write(“<h1”+s+”</h1>”) </script> </html> Functions in javascript: Prompt function:
It is used to accept any data from the user. Variable=prompt (“message”)
Return type of prompt is string
Eval function:
This is used to convert any number from string form to number form
Ex:
Eval (“10”) Eval (“10.5”)
Alert function:
It is used to display the message in dialogue box with ok button
WORKING WITH JAVASCRIPT
• Function: a function is a reusable piece of code within the program to perform the required task or operation.
• To define any function in JavaScript we use function keyword. • Syntax:
Function function name ([args list]) {
……… ………[return type] }
• In JavaScript it is always better or advisable to write function definition within the head part of the html and to call the function from the body part of the html.
Example for a function without passing arguments and without return value <html> <head> <script language="JavaScript"> function Add() {
c=a+b
document.write("<font size=5>sum is :"+c+"</font>") } </script> </head> <body> <script language="JavaScript"> Add() </script></body></html>
• Function overloading: assigning additional work to the function other than the existing work is called function overloading
• In any programming language we overload a function in two situations. 1. When no of arguments are changed
2. When data types of arguments are changed • When no of arguments are changed:
Ex: Add(int a,int b) {
……….. ……… }
• We can call the function by passing 2 args like Add(10,20)
• If we want to pass 3 args like Add(10,20,30) then it is not possible then we overload the function like
Add(int a,int b,int c)
{
……….. ………}
When data types of arguments are changed:
When data types of args are changed If we take function like
Add(int a,int b) {
……….. ……… }
possible and in this case we overload our function like
Add (float a, int b) {
……….. ………. }
In JavaScript it is not req to overload a function when no of args are changed or when data types of args are changed in boeh the cases we can use the same function
• Objects in java script
• String: it provides various properties and functions that will allow us to work with various strings
• Functions with string object
• to Lowercase()………….>converts the string into lower case letters • to Uppercase()…………..> converts the string into upper case letters • subString(Index)………..>return the remaining part of the string from
the given index
• subString(Index, Length)…>return the given length of characters from
the given index value
• charAt(Index)…………...>return the character present at the given index
• charCodeAt(Index)……..>returns the ASCII value of the character
present at the given index
• index Of(“character”)…...>returns the index value of the character
present at the given index
• split(“split string”)……….>separates the split string from the given string
• bold()………>applies the bold format for the given string • Italics()……….>applies the italic format for the given string • Strike()……….>applies the strikethrough for the given
string
• link(“urladdress”)………>creates a hyperlink to the given string with target as given url
Ex: S=“ TECHNOLOGIES” • S.toLowercase() ………..> • S.toUppercase()……….> • S.substring(7)……….> • S.substring(0,7)………..> • S.CharAt(1)………..> • S.CharcodeAt(1)………..> • S.indexof(“a”)………..> • S.indexof(“m”,2)………..> • S.Split(“TECHNOLOGIES”)………> • S.link(“www.gmail.com”)………>
• Document object: it represents the work area within the browser window
• Properties: fgColor • bgColor
• fgColor:this property is used to change the content color within the browser window
Usage document.fgColor=color value document.fgColor=“blue”
document.bgColor=“color value” document.bgColor=“yellow”
• Methods with document object: 1. Write method within one argument
Write (“message”)
This method is used to print the required message within the document Ex: document.write (“welcome”)
Ex with document object
DYNAMIC HYPERTEXT MARKUP LANGUAGE
• It is used for developing dynamic client side web applications
• The extension of this application must be saved with .htm or .html extension
• The internet explorer from 4.0 supports DHTML
• DHTML is a combination of simple text editor HTML tags CSS and scripting languages
• cascade style sheet(CSS): it is used for applying some extra formatting features on existing HTML tags
• Style represents appearance of a webpage • Style sheet is group of styles
• Css provides some list of property names and values
Syntax:
Property name: Property value Types of Style Sheets:
1. Inline Style sheet 2. Embedded Style sheet 3. External Style sheet 4. Imported Style sheet
Inline Style sheet
The style sheet whose style definition is placed under tag declaration using style attribute is called as inline style sheet.
Syntax:
<tag name style=“property name: property value; property name: property value”>
View source
<Html>
<h1 style="color: red; font-family:'verdana'; font-weight: bolder; text-align: center"> Welcome to css </h1> <input type=text style="font-size:11;color:blue;border-color:maroon;border-width:5;border-style:dotted"> </html>
Embedded style sheet: the style sheet whose style definition is placed
under style tag which automatically apply the styles on the html tags used in the program
Syntax :< style type=“text/css”> ………..
……… ……….. </style>
• Embedded style sheets are of three types
1. Tag as a selector 2. Id as a selector 3. Class as selector
• Tag as a selector : it is used for grouping the similar tags and applying the style definition
Syn:<style type=“text/css”> tag name{
……….. } Example: View source: <html> <style type=text/css> h1{ background-color:khaki;color:red; } h3{ background-color:blue;color:green; } </style>
<h1>CASCADEING STYLE SHEETS</h1> <h1>CASCADEING STYLE SHEETS</h1> <h3>CASCADEING STYLE SHEETS</h3> <h2>CASCADEING STYLE SHEETS</h2> </html>
Class as selector: it is used for grouping controls by poviding common class attribute values and its style definition should preceed with a period(.)
Syntax:
<style type=“text/css”> .t{
……… ……….
} Example: View source: <html> <style type=text/css> input{ font-size:10; } .t{ background-color:yellow } </style> <center> <h1>LOGIN FORM</h1>
<h2> <form>
Enter user name:<input type=text class=t> <br><br>
Enter password:<input type=password > <br><br>
<input type=button value=signin class=t> </form>
</h2> </center> </html>
• Id as a selector: this type of embedded style sheet is used for
grouping some set of controls by providing common id
Syntax: <style type=“text/css”> #id{ ……… ………. </style>
<tag name id=“some id”> }
View source: <html> <style type=text/css> #p{ font-size:30; } #p1{ background-color:green; } #p2{ background-color:lavender; } </style> <p id=p1>this is id selector</p> <p id=p2>this is id selector</p> <p id=p1>this is id selector</p> <p id=p>this is id selector</p></html>
Imported style sheet: it is used for importing one css program program
into another css program and also import one css program into html program.
• Imported style sheet works with a notation called as @import • Syn:@import url(‘path of css’);
• This notation is used within style tag under under .html program
Example:
View source: Code for p1.html <html>
<link rel=style sheet href="style1.css"> <h1>EXTERNAL STYLE SHEET</h1> <p>welcome to technologies</p> </html>
Code for style1.css h1, h2,h3,h4,h5,h6{ Color: red; } p{ background-color: pink; }
View source: Code for p2.html <html> <style type=text/css> @import url('style3.css'); </style>
<h1>EXTERNAL STYLE SHEET</h1> <p>welcome to technologies</p> </html>
@import url('style2.css'); p{ background-color:pink; font-size:30; font-family:arial; }
Code for style3.css h1,h2,h3,h4,h5,h6 {
color:red; }
ASP
. Net
WHY ASP. Net:
• Originally web development started with HTML but the pages designed using HTML are static WebPages because HTML is used only for designing the WebPages
• Html cannot be used to perform the validations and to execute events
• In the below figure we can design the complete webpage using html but we cannot perform The validations like Whether user entered username, password or not and events like when user clicks on button,What to do etc….
To overcome this drawback we got DHTML
Enter user name
Enter password
login
cancel
Scripting language
Client side scripting code:
In the above example if user is not entering username and password we should not submit the request to the server so to check user entered username and password etc… code should be executed within the browser only
Code that is executed within the browser only. code that is executed within the browser window to perform the events and validations is known as client side scripting code.
Programming language that is used to write client side scripting code is known as client side scripting language
Ex: javascript, vbscript, jscript etc….
• Server side technology : in the above example when user enters
username and password and clicks on login button then we should submit the webpage
To the server at server side code should be executed to check whether
Username and password are correct or not code that is executed at The Server side is known
As server side scripting code
Technologies that we use to write server side scripting code are known as server side technologies.
Ex: ASP, ASP.net, JSP
ASP. net:
• ASP. net is a server side technology or web technology used to build interactive web applications
• It is a next generation technology of Microsoft which is used to provide a new way for developing server side web applications .it is added with a dynamic nature along with some features taken from different technologies and languages
• It is a collection of html (xhtml) ,scripting languages, any one .net supportable language .
• Evolution of ASP. net : the evolution has started a decay ago by “Tim
Berne lee” who has established http protocol used for communication. Based on it the professional have developed html and xml for webpage
development and data transformation. Many companies like microsoft,sunmicrosystems, IBM was struggling to add dynamic nature in the WebPages and finally Microsoft has released its first technology for dynamic server side web application called as ASP in the year 1996.
1996 ASP 1.0 ASP 2.0 ASP 2k ASP 3.0
ASP. net 1.0 …………..>2002 (alpha) ASP. net 1.0 …………..>2003 (beta) ASP.net 1.1 ……….>2003 (alpha) ASP.net2.0 ………..> 2004 (beta) ASP.net2.0 ………> 2005 (alpha) ASP.net3.0 ………..>
ASP.net3.5 ………….> 2008 (beta)
• Asp was a powerful technology but failed in the internet market due to some problems like Interpreted execution which is very slow in process
• It is a loosely typed language which does not support any data type
• It uses difficult configuration settings for using the components to develop advanced web applications
• ASP applications crashes frequently due to unpredictable error becoz it doesn’t have a proper structured exception handling or error handling
• Asp is not a object oriented technology so it depends on some other programming language for any component requirement
To overcome these problems Microsoft has provided a new technology under .net called as ASP. Net
performance of the application.
o ASP. net supports multiple languages of .net it makes component development easy and it will be OS independent due to IL format.
o Note:ASP1.1 compiles complete web applications at once .only on language can be used.
o ASP2.0 compiles complete web application in page by page pattern. so multiple languages can be used
o .Multidevice or multibrowser support: ASP. net supports device detection due to which ASP. net Supports device detection due to which ASP. net can develop diff types o/p for different types of browsers.
o ASP. net uses easy way for configuration and deployment of the application.ASP.net maintains all its configuration settings in an xml based file which automatically configures IIS before executing the application and it uses the easy way for deployment by developing a setup file
o ASP. net is integrated under .net environment ASP. net can use all the base class libraries of .net framework for developing the web based applications
o ASP. net 1.1 class libraries are added with new class libraries and introduced in ASP. net 2.0
o ASP. net applications run under .net runtime environment i.e. CLR
o ASP. net 2.0 important feature for executing the web based application by using some concepts of the CLR like
o MEMORY MANAGEMENT:CLR will allocates memory for every user and removes its object when it is not accessible through garbage collector
o TYPE CASTING: checking the data types conversions and providing the functionalities required for execution.
o MULTITHREADING: as web applications are multi users CLR has to identify every client and allocate separate memory for it which is possible only through Threading
o ASP. net has introduced nearly 50 new controls for developing advanced web application with easy and efficient way without writing any code
o ASP. net 2.0 has provided a new technique for simplifying the application designing by introducing master pages ,themes, and skins
o ASP. net provides structural error handling ,tracing, and debugging of the application to avoid the unpredictable
Differences between ASP and ASP.net:
About IIS
Webserver:it is a tool which is used to One or more websites within it
Takes the request from the client process the request and sends the result back to the client
Ex:for windows OS Personal web server
Peers web server we cannot run ASP. net
IIS used for ASP. net
For UNIX os Tomcat
s.no ASP ASP. Net
1. It is object based technology It is object oriented technology
2. It is loosely typed language It is strongly typed language 3. ASP is bounded with scripting
language ASP.netindependent which supports is language scripting language and .net language
4. It uses difficult configuration on IIS ASP.net maintains is req configuration in an xml file 5. It supports three web servers for
execution IIS,PEARL,PERSONAL web server
ASP.net supports only IIS
6. It depends on HTML controls It provides its own controls 7. It does not supports structured error
handling It supports structured error handling 8. It depends on com tech for database
and file handling It uses .net framework class libraries for database and file handling and com components
9. It is interpreted technology It is compiled technology
To check whether IIS is present in the system or not within the system Click on start
If a window is opened named IIS console then IIS is present within the machine
If any error window appears then IIS is not present in the machine Installing the IIS if not present:
Go to run prompt Type appwiz.cpl
Click on Add windows components
Check IIS and put O.S cd and follow the steps Order of installation of software:
O.S IIS
Database (sql server/oracle) VS. net 2005
If IIS is installed after visual Studio.NET then ASP. net applications will not run properly becoz ASP. net is not registered at IIS
To reinstall the ASP. net and to register at IIS we have a separate tool as aspnet-regIIS-I
To work with this tool use the following steps
Click start click on programs click on MS.NET framework sdkv2.0 Click on sdk cmd prompt type aspnet_regIIS-I
Note: this will reinstall asp.net s/w and will register asp.net with IIS type IISreset this will stop the iis and restarts iis
Working with ASP. net applications:
Visual studio editor-2008
Open dotnet in by typing devenv in command prompt
• To develop ASP.net webforms we can develop in two editors • Simple text editoe
• Visual studio editor
• Simple text editor:when we develop a webform in simple text editor we can write userinterface and code but the configuration settings are by default considered from a predefined file machine.config
• It is available in
Select ASP. net website template select the programming language with C#.net
Select the location as HTTP type the website name(http://localhost/websitename) ok
Then automatically different windows will open
• Design window
• Source code window
• Business logic window
• Solution explorer window
• Server explorer window
• Tool box
• Property window
• When we creates any website in ASP. net by default visual Studio.NET will create the directories in two locations
• C:\inetpun\wwwroot(disk location)
• At IIS
• The directory which is created at this location is called as physical location
• All the original code files are stored in this location
• The directory created at IIS is known as virtual directory
• This directory will contain all the files with the link created to the physical directory files
• Creating virtual directory or alias is to provide security to the original files.
L ife cy c le ex e c u tio n o f A S P .n et a p p lica tio n
clien t
h ttp ://lo ca lho st/cod e1 .asp x
IIS
In etinfo.exe
a sp n et_isa pi.dll
a sp n et_ w p.exe
req u est
O /p display
p ro cess
o /p
C L R
w p .exe
w o rkp rocess
h ttp p ip e lin e s A S P . n et w o rk p ro c e s sserver
• When a client gives the url the request is forwarded to the specified web server i.e. IIS
• If the request is ASP. net then it forward the request to ASPnet-isapi.dll this file is mapped on IIS to identify asp. net request location i.e. virtual directory
• isapi.dll is forward the information through ASPnet-wp.exe(web process)
• ASPnet-wp.exe file allocates memory which is called as ASP. net work process where the execution of the request is done
• The execution of the request will uses the compilers by identifying the language used and generates the o/p by combining with user interface
• This complete process is done under CLR which sends back the response to IIS
• The communication b/n work process and web server uses pipelines • When the response is send back to the client by IIS the complete
information about the request and its process is removed from the web server
• The above point confirms that ASP. net is stateless technology
init load custom prerender unload
For every lifecycle execution of a web form .these events are fired • page_init event: used for initializing the component
• Page_load used to load the web form
• Custom event: the events which are fired by the controls of a web form • Prerender:used to send the o/ p the client by combining user interface
and the code
• Unload: as the o/p is send it is called to remove the memory of the web form
Objects in ASP. net:
• Response • Request • Session
• Cache • Trace
• Ispostback etc……..
Coding Techniques in ASP.net:
Coding techniques Designing code Programming code . A S P x
Code inline model Code behind modell
Designing
code Programming code
.aspx .aspx.cs
• Webform programming models : to develop a webform in asp.net
we have two types of models • Code inline model
• Code behind model
• Code inline: defining user interface and business logic in a single file
with .aspx is called code inline model i.e. designing and programming code are present in single file
• It is used for migrating asp applications to asp.net
• In real-time the designing of the webpage is done by the web designer
Programmer need to wait until web designer completes designing so programmers time will be wasted
• There wont be any security for programming code from the designer • Maintenance of the code is difficult
• Application development will take more time • No reusability of business logic
• Code behind model: this method separates the user interface and
business logic in two files 1. User interface in .aspx file 2. Business logic in .cs or .vb file • It reduces the maintaince cost
• increases the performance by reusability of the code
• To develop a code file we should define a class inherited from System.Web.UI.page Class
• For web based applications there are two important namespaces in asp.net
• using System.Web.dll; • using System.Web.UI.dll;
• Advantages of code behind:
• Programmer need not wait for the designing
• Security is maintained for the programming code from the designer • Application development will be completed at faster rate
Controls
Client side server side
HTML HTML
server Web server
• Control: a control is a class which provides user interface which we
can access due and perform some actions.
• Controls in asp. net are classified in to two types 1. Client side controls
2. Server side controls
• Client side controls: the controls which are supported in ASP. net
due to backward compatibility and they are executed and stored on client machine
• All html controls are client side controls • Every HTML control will run at client side • They don't provide state management
• They do not support object oriented programming
• Server side controls: the controls which stores and executes on
server system are called as server side controls • ASP. net provides two types of server controls:
1. HTML SERVER CONTROLS 2. WEBSERVER CONTROLS
• HTML SERVER CONTROLS: we can also make HTML controls to run at server side by adding the attribute runat=“server”
• Every HTML server control is a predefined class with some tag name and control name
S y s tem .W eb .U I.H tm lC o nt
ro ls.H T M lC o n trol
U s in g
S y s tem .W eb .U I.H tm lC o ntro ls
N am es p a c e
1 5
< T ext a rea >
H T M L
T exta rea
T extA rea
1 4
< s elec t> < o ptio n >
H T M L S elec t
S elec t
1 3
< d iv >
H tm lin p utG en eric c o ntrol
D iv
1 2
< h r>
H tm lin p utG en eric c o ntrol
H o rizo n ta l R uler
1 1
< ta ble> ,< td> ,<
tr>
H tm lT a ble
H tm lT a bleC ell
H tm lT a bleR o w
T a b le
1 0
< im a g e>
H tm lIm ag e
Im a g e
9
< in p ut ty p e= R a dio >
H tm lin p utR a dio B utto n
In p ut(R a dio
)
8
<in p utty p e
=C h ec k B o x
>
H tm lin p utC h ec k B o x
In p ut(C h ec k
)
7
< in p ut ty p e= File>
H tm lin p utF ile
In p ut(file
)
6
<in p utty p e
= p a s s w ord >
H tm lin p utT ext
In p ut(pa s s w ord
)
5
< in p ut ty p e= T ext>
H tm lin p utT ext
In p ut(T ext
)
4
< in p ut ty p e= s u bm it>
H tm lin p utB u tto n
In p ut(su bm it
)
3
< in p ut ty p e= res et>
H tm lin p utB u tto n
In p ut(R es et
)
2
< in p ut ty p e= b utton >
H tm lin p utB u tto n
In p ut(bu tto n
)
1
T a g
C la s s n am e
C o n tro l n am e
s n o
System.Web.UI.HtmlControls .HTMlControl HTML input control HTML container control HtmlInputButton HtmlInputText HtmlInputFile HtmlInputCheckBox HtmlinputradioButton HtmlGenericControl HtmlinputImage HtmlinputTable HtmlinputTableCell HtmlinputTablerow
WEB SERVER CONTROLS or ASP. net CONTROLS:
• All web server controls class name ,control name and tag name is same
• Every web server control should include under form tag
• All ASP. net standard controls will run at server side only by default every web server control includes run at=“server” attribute
• All web server controls are converted into HTMl controls at the time of generating the response
• ASP.net-2008 has introduced some new techniques for simplifying application designing by introducing master pages, themes and skins • All web server controls contains their own properties, events and
methods because all are inherited from a base class called System.Web.UI.WebControls. WebControl
• Every ASP. net standard control has a class like
Using System.Web.UI.WebControls.Textbox textbox Using System.Web.UI.WebControls.Button button
• All asp. net controls will provide state management
• All asp. net controls will support object oriented programming features • To create asp. net control we use the following syntax
<tag prefix: Class name id=“any id” runat=“server”> <asp: Textbox id=“TextBox1” runat=“server”>
• For every asp. net standard control equivalent HTMl code is generated on rendering
Difference between HTML controls and web server controls Sno HTML CONTROLS ASP. net standard controls
1 all html controls run at
client side Server side
2 Donot provide state
management provide state management
3 Donot contain any class for
the control Contains separate any class for each control 4 Donot support oops support oops concepts
5 Can make to run at server
side by adding
runat=“server”
By default it is server side control
Common properties for all web server controls:
Back color: it is used to change the background color of a control Border color: is used to change the border color of a control
Border style: is used to apply the style for the border like solid, double:
groove, inset, outset, dotted, dashed, none etc…
Border width: is used to change the width of the control Enabled: is used to activate or deactivate the control
Enable Theming (2.0): it is used to activate the theming for a control Font: is used to apply font name, size and style
Forecolor: is used to apply the text color Height: to apply the height of the control Width: change the width of the control
Controls in ASP. net:
• Validation controls • Navigation controls • Login controls
• Web parts controls • Ajax extensions • General controls
Discussing each control with an example:
Label: is used to place some text on the web form as a heading or as a
caption for other control Extra property: TEXT
Textbox: this control is used for accepting some text from the user and is
called as data entry control Extra property: TEXT
TEXT MODE=single line, multiline, password ROWS=SOME NO
COLUMNS=SOME NO
VALIDATIONGROUP=a validation group id READONLY=TRUE, FALSE
MAXLENGTH=used to provide the limit some no
(Valid for single line and password)AUTOPOSTBACK=T/F it is used to submit the page to the server automatically when the control lost its focus
Properties:
textbox1:autopostback=true
view source:
Protected void TextBox1_TextChanged(object sender, EventArgs e) {
Label3.Text = "hi" + TextBox1.Text; }
Checkbox : this control is used to provide selection of more than one options
from the given group of options
properties: Autopostback--->true, false
Checked……….>true/false
• Auto postback:when set to true page will be posted back to web server whenever user activates the checkbox
• When set to false page will not be posted back to web server when user activates checkbox
• Checked: stores true whenever checkbox is activated otherwise stores false.
• Default event of checkbox control is checked changed event
WELCOME TO ASP.NET
LABEL1
ENTER YOUR NAME
TEXTBOX1
LABEL2
LABEL3
Enter ur name Enter hobbies dancing playing Browsing chatting LABEL 3 SUBMIT View source:
protected void cmdsubmit_Click(object sender, EventArgs e) {
string s = txtsample.Text + "Hobbies are"; if (Chkdancing.Checked==true) { s = s + Chkdancing.Text + ""; } if (Chkplaying.Checked == true) { s = s + Chkplaying.Text + ""; } if (Chkbrowsing.Checked == true) { s = s + Chkbrowsing.Text + ""; } if (Chkchatting.Checked == true) { s = s + Chkchatting.Text + ""; } lbldisplay.Text = s;
}
example-2:
view source:
protected void Button1_Click(object sender, EventArgs e) {
//REGISTER
int rent = 0; int acost = 0;
//verify room type selectede by user if (R1.Checked)
//deluxe rent = 1000; else if (R2.Checked) //ordinary
//verify amenities selected by user if (C1.Checked)
acost = 3000; if (C2.Checked)
acost = acost + 200; //calculate the rent rent = rent + acost;
Label4.Text ="registered <br> rent/day:"+rent; }
• Redirecting the user request to other webpage or the other
• Using design controls directly • By using the code
• Using hyperlink: this control is used to redirect the user request to
any required webpage or website
• Using hyperlink control we can create the link for both picture and text • Hyperlink control does not support command name and command
argument properties
• Properties with hyperlink control: • Imageurl
• Navigate url • Text
• Image url: this property is used to set the path of image file that we
want to display in hyper link control
• Navigate url : this property is used to set the url address path to which
we would like to Redirect the user request whenever user clicks on hyper link button
Text : this property is used to set the display text to the user within the
hyperlink button
• Go to toolbox drag hyperlink …….>properties…………>text=click me--navigate url=Default2.aspx
Redirecting user request
Using design
controls
Hyperlink
Link button
Image button
Using coding
Response. Redirect
Server. Transfer
• Example:
• Creating hyperlink for text: •
• To create link for image: • Search for gif,jpeg or icon file
• Copy the required files and paste it in solution explorer of our website • Select the hyperlink---go to properties window---go to image
url property---
• Click on ellipse button---select the required image file---click on ok