Upload
ramesh-ankathi
View
53
Download
0
Tags:
Embed Size (px)
DESCRIPTION
asp dot net metrial
Citation preview
ASP.net
1
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.5 Memory Management 1.7.2.6 Just In Time Compiler
1.7.2.6.1 Pre JIT 1.7.2.6.2 Standard JIT
1.7.2.6.3 Echno JIT
ASP.net
2
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
6.4 Difference between ASP and ASP.net 7 Internet information service(IIS) 8 Working with ASP.net Applications
8.1 Why ASP.net
8.2 Evolution of ASP.net
ASP.net
3
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 11.2.5 Validation Summary with Example
11.2.6 Custom validator with Example
ASP.net
4
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 14.9.3 Check Boxes with Grid View
14.9.4 Radio Buttons with Gridview
ASP.net
5
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
ASP.net
6
MICROSOFT.NET
It is a collection of languages, technologies, frameworks, tools, libraries etc 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
ASP.net
7
.NET FRAMEWORKIt is the layer between
Application and OSIt consists of
1. CLR2. BCL
Tools:-compilerInterpreterDebugger
Assembler anddisassembler
.NET PRODUCTSMSVisual studio editor
MS Simulator
.NET Servers MSSQL Server BizTalk server IIS Mobile IIS Exchange server Internet Security ServerEtc..
.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
b. POCKET PC SIMULATOR
ASP.net
8
MS VISUAL STUDIO EDITOR: it is an integrated development
environment 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.
ASP.net
9
7).NET TECHNOLOGIES: a technology is the convergence of more than
one language for developing different applications Ex: ASP.NET is used for web applications
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
Webapplicat
Vb.net J#.net
Windowsapplicat
Mobile webapplicat
Serviceapplicat
Data IO Security
XML Threading
Memory management
CLR
Security checking
Monitoring The
Life cycle
OSARCHITECTURE 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
ASP.net
10
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
LIFE CYCLE EXECUTION OF .NET APPLICATION
.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 assemblyIL 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 reusableILARCHETECTURE: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
ASP.net
11
MANIFEST: it provides documentary information like product name, company
name, and version no, strong name etc.
PE WRAPPER: it contains some executable format which invokes the CLR.
Note: if you want to view the complete IL file then ILDASM.exe 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
ASP.net
12
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
Different types of access controllers are
1. CTS:common type system :it provides common data types for all .net
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
ASP.net
13
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
HYPER TEXT MARK UP LANGUAGE (HTML)
Web applications
Dev WebPages
Static webpage Dynamic webpage
HTML
PHOTOSHOP
FLASH
client side Server sideDHTML ASP
ASP.NET
ISP
SERVELETS
ASP.net
14
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 Server side dynamic webpage: the webpage which generates diff o/p
by processing every request on server machine which can be generated 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
ASP.net
15
Syn :
Tag contains two elements starting element and ending element
Starting element
Ending element
Every tag in HTML is predefined and optional
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:
etc.
Tags which provides only starting elements are called non container
tags
Ex :break line
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
ASP.net
16
Basic tags: these tags will provide the structure of the document
Ex:
HELLO
WELCOME TO HTML
THIS IS HTML DOCUMENT
THIS IS MY FIRST PROGRAM
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
ASP.net
17
Ex for hyper link
HELLO WELCOME TO HTML
THIS IS HTML DOCUMENT
click here to show basic tag
Text formatting tags: these tags are used to formatting the text by applying font style, size and font names etc
Ex:
BOLD ITALIC UNDERLINE SMALL FONT
Big FONT
ASP.net
18
LIST TAGS: It is used to display the information in bulleted format or numbered format
etc.. unordered list
ordered list list item
data definition data list
data table
Ex for List tags
source code:
MEMORY
PRIMARY MEMORY RAM
ROM
SECONDARY MEMORY
ASP.net
19
HARD DISC
COMPACT DISC
MULTIMEDIA TAGS: this tag is used to display the images on the text
TAG:
=SCROLLING
WELCOME
IT IS USED TO PROVIDE SOME ANIMATION AFFECTS
PROPERTIES:
ASP.net
20
Ex for multi media tag:
Source code:
WELCOME
ASP.net
21
Font tags:
Syn :
Font tags:Syn:
ArialMonotype CorsivaTimes New Roman
1 least size2
3 default size456
7 highest size
Example with font tags
ASP.net
22
View source
HI KANNABABU
HTML IS MARKUP LANGUAGE
HTML SUPPORTS FONT TAGS
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
ASP.net
23
Ex with Frame Tags
View source:
ASP.net
24
Form Tags:
FORM TAGS: it is used to design some webpage by placing some controls
It used to provide a container where we can place some controls like
Textboxes, buttons, RadioButton,etc.
Properties: method=get\post
name=some text
action=some path
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
Name=some text
Value=some text
Rows=some no
Columns=some no
Note: text area tag is noncontainer tag
ASP.net
25
Radio button control: this control is used for providing a group of options
from which we can select anyone.
To group a set of radio buttons provide common names
Syn:
Checkbox control: it is used for selecting and deselecting an item
Syn:
Dropdown list :it is used for providing some list of items from which we
can select any one in a dropdown fashion.
Syn:
..
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:
..
ASP.net
26
EX with Form tags
View source: KANNA TECHNOLOGIES
HYDERABAD
PERSONAL DETAILS FORM
ENTER YOUR NAME :
ENTER USER NAME :
ENTER PASSWORD :
ASP.net
27
SELECT GENDER : MALE FEMALE
SELECT QUALIFICATION SSC
10+2 DEGREE PG
OTHERS
SELECT HOBBIES :
DANCING PLAYING BROWSING
CHATTING
DESCRIBE YOUR SELF :
ASP.net
28
BUTTON CONTROLS
RESET BUTTON: it is used for providing a webpage with default
settings
Syn :
Submit Button: it is used for submitting the page to the specified
path mentioned in the action attribute of form tag
Syn :
Reset Button: this tag is used for invoking some functions of scripting
languages
Syn :
ASP.net
29
SCRIPTING LANGUAGES:
SCRIPTING LANGUAGES: these are used for dynamic client side web
applications
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
ASP.net
30
Java script
JavaScript is the premier client-side scripting language used
today on the Web.
Its widely used in tasks ranging from the validation of form data
to the creation of complex user interfaces.
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 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
ASP.net
31
To add JavaScript to your webpage place the tag
Ex:
Document. Write (welcome)
VARIBLES IN JAVASCRIPT
JavaScript doesnt support any predefined data types thats 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 S=WELCOME or s=welcome
document.write(s) document.write(
ASP.net
32
Functions in javascript:
Prompt function:
It is used to accept any data from the user.
Variable=prompt (message)
Ex:
A=prompt (enter first number)
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]
}
ASP.net
33
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
function Add() {
var a=10;b=20 c=a+b
document.write("sum is :"+c+"") }
Add()
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) {
.. }
ASP.net
34
When data types of arguments are changed:
When data types of args are changed
If we take function like
Add(int a,int b)
{
..
}
We can call the function by passing 2 args like Add(10,20) but if we
pass diff erent data types values like Add(10.5,20) then it is not
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
ASP.net
35
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
ASP.net
36
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 Default fgColor is black
bgColor:this property is used to change the background color of the document
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
ASP.net
37
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
ASP.net
38
Inline Style sheet
The style sheet whose style definition is placed under tag
declaration using style attribute is called as inline style sheet.
Syntax:
Example
View source
Welcome to css
ASP.net
39
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> ..
..
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:
tag name{ ..
}
Example:
View source:
h1{
background-color:khaki;color:red; }
h3{
ASP.net
40
background-color:blue;color:green;
}
CASCADEING STYLE SHEETS
CASCADEING STYLE SHEETS CASCADEING STYLE SHEETS
CASCADEING STYLE SHEETS
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:
.t{ .
} Example:
ASP.net
41
View source:
input{
font-size:10;
}
.t{
background-color:yellow
}
LOGIN FORM
Enter user name:
Enter password:
ASP.net
42
Id as a selector: this type of embedded style sheet is used for
grouping some set of controls by providing common id
Syntax:
#id{
.
}
Example
ASP.net
43
View source:
#p{ font-size:30;
} #p1{
background-color:green; }
#p2{ background-color:lavender;
}
this is id selector this is id selector this is id selector
this is id selector
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:
ASP.net
44
View source: Code for p1.html
EXTERNAL STYLE SHEET welcome to technologies
Code for style1.css
h1, h2,h3,h4,h5,h6{ Color: red;
} p{
background-color: pink; }
Example2 with imported style sheet
ASP.net
45
View source:
Code for p2.html
@import url('style3.css');
EXTERNAL STYLE SHEET
welcome to technologies
Code for style3.css
@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
46
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
DHTML:it is the combination of HTML and client side
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.
ASP.net
47
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.net
48
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 doesnt 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
FEATURES OF ASP. Net
o ASP. net is the compiled technology but not interpreted due to
this application execution will be faster and increases the 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
ASP.net
49
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
termination of the program.
Differences between ASP and ASP.net:
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.net is language independent which supports 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
ASP.net
50
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
Apache
IIS: internet information System: it will automatically come along with O.S 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
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
10. .asp .aspx
ASP.net
51
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:
Open visual studio click on file click on new click on website
Visual studio editor-2008
Open dotnet in by typing devenv in command prompt
ASP.net
52
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
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\machine.config
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
ASP.net
53
Solution explorer window
Server explorer window Tool box
Property window Error List
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.
ASP.net
54
LIFE CYCLE EXECUTION OF ASP.net
Life cycle execution of ASP .net application
client
http://localhost/code1.aspx IIS Inetinfo.exe
aspnet_isapi.dll
aspnet_wp.exe
request
O/p displayprocess
o/p
CLRwp.exe-workprocess
http pipe linesASP. net work process
server
ASP.net
55
When a client gives the url the request is forwarded to the specified web server i.e. IIS
IIS forward the request to inetinfo.exe file it checks the type of the request and forward the request to the respective engines
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 ASPnet-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
ASP.net
56
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 Application
Server Cache
Trace Ispostback etc..
Coding Techniques in ASP.net:
Coding techniques
Designingcode
Programming code
.
ASPx
Code inline model Code behind modell
Designingcode
Programming code
.aspx.aspx.cs
ASP.net
57
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 Limitations of code inline model:
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
ASP.net
58
Controls in asp. net
Controls
Client side server side
HTML HTMLserver
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
ASP.net
59
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
System.Web.UI.HtmlControls.HTMlControl
UsingSystem.Web.UI.HtmlControls
Namespace15HTML TextareaTextArea14 HTMLSelectSelect13HtmlinputGenericcontrolDiv12HtmlinputGenericcontrolHorizontal Ruler11
,,HtmlTableHtmlTableCellHtmlTableRow
Table10HtmlImageImage9HtmlinputRadioButtonInput(Radio)8HtmlinputCheckBoxInput(Check)7HtmlinputFileInput(file)6HtmlinputTextInput(password)5HtmlinputTextInput(Text)4HtmlinputButtonInput(submit)3HtmlinputButtonInput(Reset)2HtmlinputButtonInput(button)1TagClass nameControl namesno
ASP.net
60
All the HTML controls are inherited from System.Web.UI.Html.Htmlcontrol
names
System.Web.UI.HtmlControls.HTMlControl
HTML input control HTML container control
HtmlInputButtonHtmlInputTextHtmlInputFile
HtmlInputCheckBoxHtmlinputradioButton
HtmlGenericControlHtmlinputImageHtmlinputTable
HtmlinputTableCellHtmlinputTablerow
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 Any ASP. net control we create within the webpage like Textbox 1,
ASP.net
61
Textbox 2, Button 1,Button 2 are objects to the respective classes
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
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
ASP.net
62
Controls in ASP. net:
Different controls that are available in ASP.net are
Standard controls
Data controls
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
ASP.net
63
example with label and textbox :
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
ASP.net
64
Example for checkbox:
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;
}
ASP.net
65
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 rent/day:"+rent;
}
Redirecting the user request to other webpage or the other
website
ASP.net
66
User request can be redirected to any webpage or to any website we
use two ways 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
Using coding
Response. Redirect
Server. Transfer
ASP.net
67
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
Run the application and check
ASP.net
68
LINK BUTTON CONTROL: this control is used to redirect the user request to the required webpage or website
Using the link button control we can just create link to the only text and cannot create link to the images
This control supports command name and command arguments properties
Properties of link button: Command arguments
Command name Post back execution
Text PostBackurl: this property is used to set the required address path
to which we would like to redirect the user request Ex: select link button------go to properties window-----go to post
back url------click on elipse button--------select default.aspx------click ---------ok
Run the application and check
ASP.net
69
Image Button: this control is used to redirect the user request to the required webpage or website
Properties: Command name
Command arguments Image url Image url:this property is used to set the path of the image using
which we want to create hyper link
Postback url:this property is used to set the url address path to which we would like to redirect the user request when user clicks on image button
Using image button control we can create the hyperlink only for
images not for text This control will support both command name and command
arguments properties
Ex:select image button----properties----image url property----click on elipse button-------------select the req image file---------
0k Go to postback url-----------click on ellipse button and select
default.aspx
Run the app and check
ASP.net
70
Differences between Hyperlink link button and image button
Hyperlink Link button Image Button
Link can be created
to the text and also to the
image
Link can be created to the text only and
cannot be created to the image
Link can be created to the image only and cannot be
created to the text
It doesnot
support command
name an command
arguments properties
support command name
an command arguments properties
support command name an
command arguments properties
ASP.net
71
Redirecting the user request using coding
Response. Redirect(Default2.aspx); Ex:
Server. Transfer(Default2.aspx);
Response.Redirect("Default2.aspx"); Server.Transfer("Default2.aspx");
Differences between Response.Redirect and Server.transfer
Server.transfer Response.Redirect
Used to redirect to any webpage in any website present in the same webserver
Used to redirect to any webpage in any website present in the same webserver or in different webserver
Execution is fast Execution is slow
Cannot be user to pass any values to
the destination page
Can be user to pass any values
to the destination page
Button Controls:
ASP. net has provided three button controls for submitting information to the server
BUTTONS
PUSH BUTTON LINK BUTTONIMAGE BUTTON
ASP.net
72
THIS CONTROL IS USED TO PROVIDE EVENT-HANDLING FACILITY OR TO EXECUTE THE REQUIRED CODE WHENEVER USER CLICKS ON
IT Properties:
Command name Command arguments
Post back url Command name: this property is used to identify the control from which
event has been raised when same function or same event has been called from button controls
Command arguments: this property is used to parse the required value to the server whenever a user clicks on a button
Note: we can use the above properties only with command event of the button control and we cannot use with click event Post back url: this property is used to redirect the user request to any
webpage or website whenever user clicks on button Events :an event is a member of a class which is used to perform some
kind of action or operation The event will not be called every time rather at particular time period
only event will be called known as event firing or event raising
EatingDrinkingsinging
personevents
Whenever person gets hungry then only eating event will fire
Events associated with button controls:
Click event Command event Click event: this event will be fired when user clicks on the button This event does not support command name and command argument
properties
Command event: this event is fired whenever user clicks on the button
This event supports command name and command argument
ASP.net
73
Example with Click event:
textbox1
RED Green BLUE
View source:
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.BackColor = System.Drawing.Color.Red;
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.BackColor = System.Drawing.Color.Green;
}
protected void Button3_Click(object sender, EventArgs e)
{
TextBox1.BackColor = System.Drawing.Color.Blue;
}
ASP.net
74
Example2 with click event:
Divide
cmdAdd cmdSubtract cmdMultiply cmdDivide
Enter first no
Enter second no
txtResult
txtNum2
txtNum1
Result
subtract Multiply Add
Arithmetic problem.aspx
View source: int a, b, c; protected void Button1_Click(object sender, EventArgs e)
{ a= Convert.ToInt32(TextBox1.Text); b= Convert.ToInt32(TextBox2.Text); c=a+b;
TextBox3.Text=c.ToString(); } protected void Button2_Click(object sender, EventArgs e)
{ a= Convert.ToInt32(TextBox1.Text);
b= Convert.ToInt32(TextBox2.Text); c=a-b;
TextBox3.Text=c.ToString(); }
protected void Button3_Click(object sender, EventArgs e)
ASP.net
75
{
a= Convert.ToInt32(TextBox1.Text); b= Convert.ToInt32(TextBox2.Text);
c=a*b; TextBox3.Text=c.ToString();
} protected void Button4_Click(object sender, EventArgs e)
{ a= Convert.ToInt32(TextBox1.Text);
b= Convert.ToInt32(TextBox2.Text); c=a/b;
TextBox3.Text=c.ToString(); }
Example with command event: Calling same function from two or more buttons
Select button1--properties--click on event---and type F1 and press enter Select button2--properties--click on event---and type F1 and press
enter
Enter any text
button1 button2
View source
Protected void F1(object sender, EventArgs e) {
TextBox1.Text = "welcome"; }
Calling same function to perform the arithmetic operations when user cicks on different buttons
1. Add the following command names to the buttons
ASP.net
76
cmdAdd ---------Add
cmdSubtract----subtract cmdMultiply----Multiply
cmdDivide------Divide 2. Call the same function F1 from command event of all buttons 3. Write the following code
Divide
cmdAdd cmdSubtract cmdMultiply cmdDivide
Enter first no
Enter second no
txtResult
txtNum2
txtNum1
Result
subtract Multiply Add
Arithmetic problem.aspx
View source: assignment
Listing Controls This control will provide some list of items in a different appearance
from which we can select a single or multiple items ASP. net 2.0 has introduced five types of listing controls
List Box: Dropdown list: Radio Button
Bulleted List Common properties for first 3 list controls: Auto post back=T/F
ASP.net
77
Data source Id=some collection
Data member=some collection Datatextfield=column name
Items=some items Events: selected index change
List Box: is used for selected single or multiple items by providing a list of items.
Property: selection mode=single/multiple Rows: some no
Dropdown list: used to display some collection of items in a dropdown from which w can select any one
Checkbox List: it is a combination of checkbox and a List Box it supports
multiple selection of items Properties:
cell padding=some no Cell spacing=some no Repeat columns=some no
Repeat direction=horizontal/vertical Repeat layout=table /flow
Text align=left/right Radio Button List: supports only one item selection and is the
combination of radio button and list box Properties are same as Checkbox List
Bulleted List Box: it is used to display information in bulleted format or numbered format
Properties: Bulleted style=numbered/lower arguments/upper arguments etc.
First Bulleted number=some no Panel control: this property is used for grouping some control for
common alignment and applying some common properties
Page.IsPostback:this property is used for checking whether page is loaded or reloaded
It returns false when the page is loaded for the first time otherwise returns true.
ASP.net
78
ASP.net
79
Validation controls
Validation: it is a process of restricting the control by accepting the
proper input from the user i.e. it is a process of checking the values are valid or not
Validations are of two types Client side validations
Server side validations
s.no Client side validations Server side validations
1. Validating a webpage before
submitting the information is called as client side validation
Validating a webpage on the server
after submitting the information is called as server side validation
2. It can be perform using client
side script code return using
scripting languages
It can be perform using the code
placed on a server return by any
.net language
3. Provides faster response Provides slow response
4. Browser dependent Browser independent
If a webpage should validate properly and fastly then we have to use
client side and server side validations But this process increases burden on the programmer to overcome this
problem MS. net has introduced 6 types of validation controls which are inherited from System.web.UI.WebControls.BaseValidator
1. Required Field validator 2. Range Validator
3. Regular expression validator 4. Compare Validator
5. Customer Validator 6. Validation Summary-----------------displaying validation error
messages
ASP.net
80
common properties for all validation controls:
ControlToValidate =some control id Error Message=some text
Text=some message Display=static, dynamic none
Is Valid=T/F Enabled Client Script=t/F
Set focus on error (2.0): t/f I is used to focusing the control when it contains invalid value
ValidationGroup(2.0):some text or group ID
Required Field validator: used to check whether the the i/p control contains value or not and if the value is not existing it provides error
message this control is used to check the emptiness of the control that we are validating
If the control that we are validating doesnt contain any value then required field validator will return false to the webpage
If the control that we are validating contains any value then required
field validator will return True to the webpage Control to validate: this property is used to set the name of the control
that we are validating using req field validator Error Message: this property is used to set the req message that is to
be displayed when req field validator returns false Extra property: initial value=some text
Example
ASP.net
81
Properties:
Design: drag and drop required field validator Properties of required field validator are
Control to Validate=TextBox1 Error Message=TextBox should contain some Text
Range validator: this control is used to check or validate user entered data within the given range or not
Extra properties: Maximum Value :this property is used to set the highest value with
which we would like to compare the user entered data Minimum Value: this property is used to set the highest value with
which we would like to compare the user entered data Type: this property is used to set the required datatype with which we
would like to compare the user entered data Type=integer/string/double/date etc.
example
ASP.net
82
Properties:
Design: drag and drop range validator Properties of range validator are
Control to Validate=TextBox2 Error Message=invalid age
Maximum value=25 Minimum Value=18
Type=integer Compare validator: this control is used for comparing to controls or
used for comparing a control with the value If both the controls contents are same then compare validator will
return true otherwise false Properties:
control to compare: this property is used to set the control name with which we want to compare the contents of the control that has
been set in control to validate property Control to compare =some id Value to compare=some value
Operator=equal, not equal, etc Type:string,Integer,double,Date etc.
Example
ASP.net
83
Properties:
Go to toolbox drag and drop compare validator Control to validate=TextBox2
Control to compare =TextBox1 Operator=equal
Type: string, Regular expression validation: this control is used to check or
validate whether user entered data is within the required format or not like email id form or internet url address or phone no or in pin code
format no If user entered data matches with the set format then reg expression
validator will return true to the webpage otherwise false Properties:
Control to validate: Error Message:
Properties: Go to toolbox drag and drop Regular expression validator. Validation expression=select internet url address
ASP.net
84
Validation Expression: this property is used to set the required
expression f format with which we want to compare There are predefined expressions available to compare and also we
can write our own expressions This control is used to perform the validations whenever existing
validation controls donot make the user requirements This control is used to perform both client side and server side
validations This is the only control in complete validation controls which is used to
perform both client side and server side validations Properties
Control to validate Client validation functions
Error message
Validation summary: it is used to display all the error messages in that webpage This control is not used to perform any validations rather it will display all other validation controls error messages as a group
together
User name Required fiels validator
password Required fiels validator
Retype password Compare validator
Age Range validator
Submit Validation summary
Example:
Drag and drop validation summary
ASP.net
85
Client validation functions: this property is used to set the required
java script function using we want to validate the required control data
Example using custom validator to perform client side validations
Example using custom validator to perform client side validations
Properties
Control to validate=textbox2.text
Error message=password should contain min of 6 characters
Client validation functions =F1
Enter username
Enter password Custom validator
submit
Go to source part of the html page and write the JavaScript function
code like
function F1(X,Y)
{ if(Y.Value.length>=6)
{ Y.IsValid=true;
}
else { Y.IsValid=false; }}
Button1_Click
ASP.net
86
{ Response.Redirect("page submitted");}
To perform client side validations using custom validator control
whatever the function we define the function should contain 2 args always
1st arg will store the type of the control from which function has been called
2nd arg contain 2 important properties Value
IsValid Value: property stores the data entered by user in the control that we
are validating IsValid:this is a boolean property stores True/false and will return
either true or false to custom validator control when function execution is completed
Example to perform server side validations using custom validator control
In the above example we perform the validation to check password is
kanna or not If user enters password > kanna then we display a message as
page submitted otherwise error message displayed
Enter username
Enter password Custom validator
submit
Properties
Control to validate=textbox2.text Error message=password
Select custom validator ..> goto properties window..>click on events button..>double click on server validate event write the following code
protected void Page_Load(object sender, EventArgs e)
{ }
ASP.net
87
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args) {
if (args.Value == "kanna") {
args.IsValid = true; }
else {
args.IsValid = false; }
} protected void Button1_Click(object sender, EventArgs e)
{ if (Page.IsValid == true)
{ Response.Write("page is submitted"); }
} Navigation controls: these controls are used for fast navigation between
the web page on a website Some of the navigation controls are
MENU TREE VIEW
SITEMAP PATH CONTROL These controls are introduced only in 2.0 which we have to develop
using scripting languages or we have to download from Microsoft control gallery in the previous versions of Asp. Net
MENU CONTROL: Properties:
Disappear After=some millisecond
Items=Root, adding root, adding child, removing item Items-----text, navigate url,image url,value Dynamic menu style=some color Example :
Step1: go to toolbox drag and drop menu control Step2: select menu controls properties
Items=add root item----select new item---Text=HOME
similarly
Add ABOUTUS,CONTACT US Step3: select HOME navigate url=home.aspx
select ABOUTUS navigate url=aboutus.aspx select CONTACTUS navigate url=contactus.asp
ASP.net
88
step4:add home.aspx aboutus.aspx contactus.aspx to the existing
project
Step 5: Debug and check the output
TREE VIEW CONTROLS: This control is used for displaying some information in a branched tree structure format with expansion and collapsion
It always display in a vertical manner and does not support different
property for dynamic and static displaying Properties: Disappear After=some millisecond Nodes=Root, adding root, adding child, removing item
Nodes--text, navigate url,image url,value
Dynamic menu style=some color Example:
Step1: go to toolbox drag and drop treeview control Step2: select menu controls properties
Nodes=add root item----select new item---Text=HOME similarly
Add ABOUTUS,CONTACT US Step3: select HOME navigate url=home.aspx
select ABOUTUS navigate url=aboutus.aspx
select CONTACTUS navigate url=contactus.asp step4:add home.aspx aboutus.aspx contactus.aspx to the existing
project
ASP.net
89
Example:
SITE MAP PATH CONTROL: this control is used for providing the navigation information information of a menu or a tree view control
It helps to navigate between the pages by providing navigation information on the top or bottom of the web page
This control requires a sitemap file which is based on xml We cannot directly work with sitemap path control to work with
sitemap we have to go either menu control or tree view control Steps to work with sitemap path control
Step1: drag and drop menu control Step2: go to website--- add new item- select sitemap---ok S