November 2, 2017 | Author: unisysselvam | Category: Java Script, Cascading Style Sheets, Html Element, Active Server Pages, Microsoft Visual Studio
Share Embed Donate

Short Description



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 1.1 1.2 1.3 1.4

Microsoft Development technology Versions Of Features according to versions of .net Framework 1.4.1 framework 1.4.2 Microsoft Products 1.4.3 Services 1.4.4 Servers 1.4.5 Tools 1.4.6 Languages 1.4.7 Technologies

1.5 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 CTS CLS CAS RBS

4                                                                             Memory Management Just In Time Compiler Pre JIT Standard JIT Echno JIT

3 4



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 Scripting Languages 3.1 Different Types of Scripting languages 3.2 Features Of scripting Languages 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 Dynamic Hypertext Markup Language 5.1 Cascading style sheets 5.1.1 Types Of CSS Inline style sheet Embedded style sheet tag as selector class as selector ID as selector External style sheet Imported style sheet ASP.NET 6.1 Why 6.2 Evolution of 6.3 Features of 6.4 Difference between ASP and 5                                                                                      7 Internet information service(IIS) 8 Working with Applications 8.1 Why 8.2 Evolution of 8.3 Features of 8.4 Difference between ASP and 9 Coding Techniques in 9.1 Code inline model 9.2 Code behind model 10 Controls in 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 10.3.1 Standard controls and examples Label TextBox with Example CheckBox with Example 10.3.2 Redirecting The user Request Hyperlink Button with Example Link Button with Example Image Button with Example Differences b/n button controls Response. Redirect Server. Transfer 10.3.3 Button controls Events with Button Controls Click Event with Example Command Event with Example 10.3.4 Listing Controls ListBox DropDownList RadioButtonList CheckBoxList 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 6                                                                                      11.2.5 Validation Summary with Example 11.2.6 Custom validator with Example 12 Navigation Controls 12.1 Menu Controls with Example 12.2 Treeview Controls with Example 13 Calendar control with example 14 14.1 introduction to 14.1.1 I-layered approach 14.1.2 II-layered approach 14.1.3 III-layered approach 14.2 ADO vs 14.3 architecture diagram 14.4 Connection oriented architecture 14.4.1 Data Providers in 14.4.2 Objects in 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 Steps to work with Dataset 14.6 Data Bound Controls 14.6.1 Templates 14.6.2 Types Of Data Bound Controls Repeater Control Data list Control 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 7                                                                                     

15 16 17 18 19


Ad Rotator Control CSS in Themes and Skins Master Pages State Management in 15.1 View state 15.2 URL encoding 15.3 Cookies 15.4 Sessions 15.5 Application 15.6 Caching 15.7 Query String 500 Frequently asked questions

MICROSOFT.NET 8                                                                                     

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


1.0:-introduced 1.0:-introduced 1.1:-introduced 2.0:-introduced 2.0:-introduced 3.0 3.5

in in in in in

the the the the the

year year year year year

2000 2002 2003 2004 2005

(beta) (alpha) (alpha) (beta ) (alpha)

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

.NET Services .NET PRODUCTS Passport service MSVisual studio editor • • Calendar service MS Simulator • Contact Service • Alert Service • Web service  Etc….

.NET Servers • MSSQL Server • BizTalk server • IIS • Mobile IIS • Exchange server • Internet Security Server Etc……..

Tools:­compiler Interpreter Debugger Assembler and disassembler

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


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 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 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 language for developing different applications Ex: ASP.NET is used for web applications 11                                                                                      ADO.NET is used for database handling WEBSERVICES are used for complete distributed applications ARCHITECTURE OF Application layer

Windows applicat

Web applicat

Data Base class layer Mobile web applicat


Memory  management


Service applicat

Security Threading

CLR Security  checking

Translating layer

Monitoring  The Life cycle


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

12                                                                                      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 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: 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…. 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 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 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.








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


understandable format use it and maintain the copy in the temporary location for the next request



Web applications Dev WebPages

Static webpage

Dynamic webpage


client side DHTML



• • •

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

16                                                                                      •

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 •


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 : Tag contains two elements starting element and ending element

Starting element

Ending element

Every tag in HTML is predefined and optional

17                                                                                      •

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………


Basic tags: these tags will provide the structure of the document Ex: HELLO 18                                                                                      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

link h1 F1.html • •


Cross link: it is used for linking same document different paths Anchor tag is used for linking

Ex for hyper link

19                                                                                      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 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 HARD DISC COMPACT DISC MULTIMEDIA TAGS: this tag is used to display the images on the text •


=SCROLLING 21                                                                                      WELCOME •



Ex for multi media tag:


Source code: WELCOME

Font tags: Syn :

23                                                                                      • Font tags: Syn :         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

24                                                                                      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

Ex with Frame Tags


View source: where skin file is maintained Using web.config file: go to web.config file Example with THEMES AND SKINS: STEP-1: Open devenv---default.aspx--and design the following webpage

Step-2: go to website---add new item---and design default2.aspx as

Step-3: go to website-add new item--select skinfile--addyes-- automatically App_Themes\SkinFile\ will be added--delete the code available in the skinfile--and write the following code Step-4: go to Default.aspx and write the following code Similarly go to Default2.aspx and write the following code Step-5: execute default.aspx and Default2.aspx and check the output the skin file is applied to every page o/p:


Master pages are used to provide a practical solutions for page templating .this is anewconcept introduced from ASP.net2005 .it is used to maintain the part of the webpage as constant through out the website. Example: Step-1: Start-run--devenv--create website---add new item-- Select master page template--add Step-2: cut the content place holder --go to layout--insert table--select template-select header ,footer and side template

Step-3: paste the content place holder in C

Step—4: place some image in A Step-5: drag and drop a tree view control in B

Step-6: execute the default page and execute. STATEMANAGEMENT IN ASP. Net

• • • •

• 1. 2. 3. 4. 5. 6.

It is the process of maintaining some information between multiple requests and responses It is also defined as an art of retaining values between multiple web pages As Asp .net is a stateless technology where with every request a page object is created on the server and with every response the object is destroyed on the server If we consider a website like online shopping where user can select multiple items to buy with each request the object is created then all the items details may not maintain to generate a bill.becoz of ASP. net stateless nature. in this criteria we need to maintain the information about the selected items in a temporary memory either on the client or on the server machine to perform this operation ASP .net has introduced state management state management is ASP .net contains 6 types View state URL encoding Cookies Sessions Application Caching

1. View state: it is one of the state management concept which is used for maintaining the state of a control in around trip fashion i.e. submitting the data to the server and getting the response back to the client • It maintain the information on the server under a collection class called as System.Web.UI.StateBagClass and on the client machine it is maintained in terms of a hidden field with a name – view state • The value which is maintained in view state is in a base 64 format which is easy to read a hexa decimal value • Any hacker can perform reverse engineering to the base 64 value and can get the actual value from it • To provide security for our view state data • ASP .net has provided two ways 1. Using EnableViewStateMacAttribute 2. Using Encrypting the data • Using EnableViewStateMacAttribute :This attribute generates strong check sum value which is a crypto graphical hash code •

When the page is submitted to the server this checksum is maintained on the client and is compared with the response value if both matches accept the page otherwise rejects the page • Html code window: • 10 Request.QueryString[“b"] or Request.QueryString[1] ………….>20 Request.QueryString[“uname"] or Request.QueryString[2] ………….>kanna Disadvantages of query string As query string transfers the data in plain text format and data is visible within the address bar query string cannot be used to pass the sensitive information like password, etc… Maximum limitation for address bar of any browser window is 4 kb(4096 bytes), so we cannot transfer more than 4 kb of information using query string (this 4kb uses url address also)

Ex with query string:

Default.aspx Enter value for a Enter value for b submit

Enter value for a Enter value for b submit

Code for Default.aspx Button1_Click { Response.Redirect("Default2.aspx?a="+ TextBox1.Text +"&b=" + TextBox2.Text); } • Code for Default2.aspx Page_Load { TextBox1.Text = Request.QueryString["a"].ToString(); TextBox2.Text = Request.QueryString[1].ToString(); } •


• Example with database •

Enter deptno submit Default4.aspx

Default3.aspx Designatio Ename  Doj n




Xxx Xxx xxx

Code for default3.aspx Button1_Click { Response.Redirect("Default4.aspx?dno="+TextBox1.Text); } Code for default4.aspx •

SqlConnection con; SqlDataAdapter da; DataSet ds; protected void Page_Load(object sender, EventArgs e) { con = new SqlConnection("integrated security=yes;database=kanna;data source=localhost"); da = new SqlDataAdapter("select * from empdetails where deptno="+Request.QueryString["dno"].ToString(),con); ds = new DataSet(); da.Fill(ds, "empdetails"); GridView1.DataSource = ds; GridView1.DataMember = "empdetails";

GridView1.DataBind();} Default.aspx Enter username


Enter password label3 Empid pkey cancel Login.asmails px:


SESSION: a session is some information maintained on a server machine • Session is accessible by all the WebPages of a website • A session is created separately for every user • Session supports server side state management where the complete information is maintained on the server machine • For every client which gives the request to the server is identified by the web server by creating a session for that session a session id is created which is 120 bit hexa decimal unique value. • Session id is a encrypted format and no hacker can perform reverse engineering to it • To maintain this session id asp .net supports 1. Cookies 2. Urlencoding • Cookie: when the client gives the request a session is created on the server and its session id is maintained in in-persistent cookie on the client machine by sending it along with the response for the next request and the response the session id is taken to the server and the client •

Cookie Session id

Request1  Session  Response+SessionID 

Session id­sessionid ID  n o i s Ses + 2 t   ues q onID i e s R s e 2 +S e s n po Res

• 2.


4. 5. 6.

The cookie which is maintained the session information the client machine uses as a name url encodeing:the session id information can also be maintained along with the url of the application where every request and the response takes the session id between client and server http://localhost/appname/(sessionid)/filename.aspx To use this type of session maintenance we should go to web.config file To create session manually asp. Net has provided a predefined object or a property called as Page.Session The session object is actually an object of System.Web.Sessionstate.Httpsessionstate the session objects provides some methods and properties methods: Apattern Add Clear Remove RemoveAll

RemoveAt 7. properties:Cookiemode Count Mode IsCookieless SessionId Keys TimeOut (specified the life span for session default life span for session is 20 minutes) • Creating a session: • Syn : Session[“name of the session”]=some value; • To get value variable=Session[“name”];



Page_Load(object sender, EventArgs e) { if (Session["Visit"] == null) Session["Visit"] = 1; else { int i = (int)Session["Visit"]; i++; Session["Visit"] = i; } Label1.Text = "you have visited:" + Session["Visit"] + "time"; } • To disable the session for complete web application go to web.config file • To disable the session for a webpage •



View more...


Copyright ©2017 KUPDF Inc.