0% found this document useful (0 votes)
50 views

Unit1_Introduction_ASP_2022

Uploaded by

pjay27470
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Unit1_Introduction_ASP_2022

Uploaded by

pjay27470
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

ASP .

NET – 505 (TYBCA Sem – 5)

Unit 1
Introduction to ASP .NET
- What is ASP .NET
- .Net framework 2.0
- Compile code
• Code Behind and Inline Coding
- The Common Language Runtime
- Object Oriented Concepts
- Event Driven Programming

1.1. Introduction to .Net Framework


­ The .NET Framework is a software development platform that was introduced by
Microsoft in the late 1990 under the NGWS (Next Generation Windows
Services). On 13 February 2002, Microsoft launched the first version of the .NET
Framework, referred to as the .NET Framework 1.0.
­ It is a virtual machine that provide a common platform to run an application that
was built using the different language such as C#, VB.NET, Visual Basic, etc. It is
also used to create a form based, console-based, mobile and web-based
application or services that are available in Microsoft environment.
­ Furthermore, the .NET framework is a pure object oriented, that similar to
the Java language. But it is not a platform independent as the Java. So, its
application runs only to the windows platform.
­ The main objective of this framework is to develop an application that can run on
the windows platform. The current version of the .Net framework is 4.8.
­ The .NET Framework is not only a language, but it is also a software and
language neutral platform.
­ The .Net Framework supports more than 60 programming languages such as
C#, F#, VB.NET, J#, VC++, JScript.NET, APL, COBOL, Perl, Oberon, ML,
Pascal, Eiffel, Smalltalk, Python, Cobra, ADA, etc.

Dr. Priyanka Mehta (Assist. Prof.) Page 1


ASP .NET – 505 (TYBCA Sem – 5)

.Net Framework Timeline

1.1.1. Features of .Net Framework


­ Following are the features that make .NET a wonderful platform for developing
modern applications.
1) Object Oriented Programming System
 Visual Studio .NET provides a fully object oriented environment.
 Visual Studio .NET supports OOPs concepts.

2) In-built Memory Management


 Developers always worry for system resources like memory.
 Visual Studio .NET supports handling memory on its own.
 The garbage collector takes responsibility for freeing up unused objects at
regular intervals.

3) Rich set of Classes


 In C and C++ programs uses header files like “stdio.h”, “iostream.h” etc.
 Visual Studio .NET contains hundreds of classes and namespaces that
provides variety of functionality in applications.

Dr. Priyanka Mehta (Assist. Prof.) Page 2


ASP .NET – 505 (TYBCA Sem – 5)

 For e.g. to work with database we need to use System.Data namespace.

4) Multi-Language and Multi-Device support


 Visual Studio .NET supports multiple languages.
 This means that if your friend has skills in C++, and you have skills in VB you
both can work in same application. You can write logic in C# and they can
write in VB .NET.
 The beauty of multi language support lies in the fact that even though the
syntax of each language is different, the basic environment of developing the
software is same.
 Visual Studio .NET supports Multi-Device.
 We can create mobile or PDA etc. device supported software.

5) Faster and easy development of web applications


 ASP .NET is useful for developing dynamic and database related web
applications.
 ASP .NET contains rich and faster development controls for web applications.

6) XML support
 Visual Studio .NET supports for writing, manipulating and transforming XML
documents.

7) Ease of development and configuration


 Deploying windows applications especially that used COM components were
always been a tedious task. Since .NET does not require any registration as
such, much of the deployment is simplified.

1.1.2. .Net Framework Architecture


­ .Net Framework Architecture is a programming model for the .Net platform that
provides an execution environment and integration with various programming
languages for simple development and deployment of various Windows and
desktop applications.
­ It consists of class libraries and reusable components.

Dr. Priyanka Mehta (Assist. Prof.) Page 3


ASP .NET – 505 (TYBCA Sem – 5)

Components of .NET Framework


­ There are following components of .NET Framework:

1. CLR (Common Language Runtime)


2. CTS (Common Type System)
3. BCL (Base Class Library)
4. CLS (Common Language Specification)
5. .NET Assemblies
6. XML Web Services
7. Window Services

1. CLR (Common Language Runtime)

 It is the execution engine for .NET framework applications.


time environment which executes the code written in any .NET
 It is a run-time
programming language.
 It is backbone of .NET architecture.
 It works as a layer between Operating Systems and the applications written in
.Net languages.
Dr. Priyanka Mehta (Assist. Prof.) Page 4
ASP .NET – 505 (TYBCA Sem – 5)

 The main function of Common Language Runtime (CLR) is to convert the


Managed Code into native code and then execute the Program.
 The Common Language Runtime (CLR) 's Just In Time (JIT) compiler
converts Microsoft Intermediate Language (MSIL) which is also known as the
CIL(Common Intermediate Language) or IL(Intermediate Language) to native
code on demand at application run time.

 Other functions,
I. Memory Management
II. Verification of type safety
III. Access to metadata
IV. Code access Security
V. Exception Handling
VI. Garbage collection

2. CTS (Common Type System)

 CTS allow programs written in different programming languages to easily


share information.
 A class written in C# should be equivalent to a class written in VB.NET.
 Languages must agree on the meanings of these concepts before they can
integrate with one another.
 CLS forms a subset of CTS. This implies that all the rules that apply to CTS
also apply to CLS.
 It defines rules that a programming language must follow to ensure that
objects written in different programming languages can interact with each
other.
 CTS provide cross language integration.
Dr. Priyanka Mehta (Assist. Prof.) Page 5
ASP .NET – 505 (TYBCA Sem – 5)

 The common type system supports two general categories of types:


I. Value types
II. Reference types

I. Value types
 Stores directly data on stack.
 In build data type.
 Example: dim a as Integer
II. Reference types
 Stores a reference to the value’s memory address, and are allocated on
the heap.
 Example: dim obj as new Oledbconnection

3. BCL (Base Class Library)

 It is also known as framework class library (FCL).


 .NET Framework Class Library is the collection of classes, namespaces,
interfaces and value types that are used for .NET applications.
 It contains thousands of classes that support the following functions.

 Base and user-defined data types


 Support for exceptions handling
 input/output and stream operations
 Communications with the underlying system
 Access to data
 Ability to create Windows-based GUI applications
 Ability to create web-client and server applications
 Support for creating web services

4. CLS (Common Language Specification)

 It is a subset of CTS.
 It defines a set of rules and restrictions that every language must follow which
runs under the. NET framework.
 CLS includes basic language features needed by almost all the application.
 It serves as a guide for library writers and compiler writers.

5. .NET Assemblies

 A .NET assembly is the main building block of the .NET Framework.

Dr. Priyanka Mehta (Assist. Prof.) Page 6


ASP .NET – 505 (TYBCA Sem – 5)

 It is a small unit of code that contains a logical compiled code in the Common
Language infrastructure (CLI), which is used for deployment, security and
versioning.
 It defines in two parts (process) DLL and library (exe) assemblies.
 When the .NET program is compiled, it generates a metadata with Microsoft
Intermediate Language, which is stored in a file called Assembly.

6. XML Web Services

 Web-Based applications come under this category.


 ASP.Net is a framework for web and it provides the awesome integration of
HTML, CSS and JavaScript which makes it useful to develop the web
applications, websites and web services.
 Web services were added in .Net Framework 2.0 and considered as a part of
ASP.NET web applications.

7. Window Services

 Form Based applications are considered under this category


 In simple terms, we can say client-based applications which read and writes
the file system comes under this category.

1.1.3. What is an assembly?


­ An assembly is the main building block of the .NET Framework.
­ It is a small unit of code that contains a logical compiled code in the Common
Language infrastructure (CLI), which is used for deployment, security and
versioning.
­ It defines in two parts (process) DLL and library (exe) assemblies.
­ When the .NET program is compiled, it generates a metadata with Microsoft
Intermediate Language, which is stored in a file called Assembly.

1.1.4. What is metadata?


­ Metadata means data about data.
­ Metadata is information stored in the assembly that describes the types and
methods of the assembly and provides other useful information about the
assembly.
­ Assemblies are said to be self-describing because the metadata fully describes the
contents of each module.
­ The CLR uses this metadata to

Dr. Priyanka Mehta (Assist. Prof.) Page 7


ASP .NET – 505 (TYBCA Sem – 5)

 Locate classes
 Load classes
 Generate native code
 Provide security

1.1.5. What is Namespace?


­ .NET framework class library is a collection of namespaces.
­ Namespace is a logical naming scheme for types that have related functionality.
­ Namespace means nothing but logical container or partition.
­ It’s like drives of the computer.
­ At the root of the hierarchy is the System namespace.
­ Common namespaces

Namespace Description
System Contains fundamental classes and base classes
System.IO Contains classes for reading and writing data in file
System.XML Contains classes to work with XML
System.Windows.Forms Contains classes for windows-based applications
System.Data Contains classes for the database connection

Difference between Client Side Scripting and Server Side Scripting

Client Side Scripting Server Side Scripting


Executes on client side Executes on server side
Do not have access to server Can access server resources.
resources.
JavaScript or VBScript Asp.net, PHP, JSP
Faster Slower
Exa: Validation form Database related task
More responsive Less Responsive

1.2. What is ASP .NET?


­ ASP .NET is Not ASP.
­ ASP stands for Active Server Pages.
­ ASP .NET is the next generation of ASP, but it's not an upgraded version of ASP.

Dr. Priyanka Mehta (Assist. Prof.) Page 8


ASP .NET – 505 (TYBCA Sem – 5)

­ Like ASP, ASP.NET is a server-side technology.


­ ASP.NET is an entirely new technology for server-side scripting. It was written
from the ground up and is not backword compatible with classic ASP.
­ ASP.NET is the major part of the Microsoft's .NET Framework.
­ ASP.NET is a server side scripting technology that enables scripts (embedded in
web pages) to be executed by an Internet server.
­ ASP . NET provides services to allow the creation, deployment, and execution of
Web Applications and Web Services.
­ ASP.NET is a programming framework built on the common language runtime
that can be used on a server to build powerful web applications.
­ ASP.NET Microsoft Technology.
­ ASP .NET is a program that runs i-nside IIS.
­ IIS (Internet Information Services) is Microsoft’s Internet server.
­ IIS comes as a free component with Windows servers.
­ IIS is also a part of Windows 2000 and XP Professional.
­ Web Applications are built using Web Forms.
­ ASP.NET comes with built-in Web Forms controls, which are responsible for
generating the user interface. They mirror typical HTML widgets like text boxes or
buttons. If these controls do not fit your needs, you are free to create your own
user controls
­ Web Forms are designed to make building web-based applications as easy as
building Visual Basic applications.
­ ASP.NET defines an application as the sum of all files, pages, handlers, modules
and executable code that can be invoked or run in the scope of a given virtual
directory (and its subdirectories) on a Web application server.
­ For example, an "order" application might be published the "/order" virtual
directory on a Web server computer. For IIS the virtual directory can be set up in
the Internet Services Manager; it contains all subdirectories, unless the
subdirectories are virtual directories themselves.
­ Each ASP.NET Framework application on a Web server is executed within a
unique .NET Framework application domain, which guarantees class isolation
(no versioning or naming conflicts), security sandboxing (preventing access to
certain machine or network resources), and static variable isolation.
­ ASP.NET maintains a pool of HttpApplication instances over the course of a Web
application’s lifetime
­ ASP NET automatically assigns one of these instances to process each incoming
HTTP request that is received by the application. The particular HttpApplication
instance assigned is responsible for managing the entire lifetime of the request
and is reused only after the request has been completed. This means that user
code within the HttpApplication does not need to be reentrant.

Dr. Priyanka Mehta (Assist. Prof.) Page 9


ASP .NET – 505 (TYBCA Sem – 5)

WHAT CAN I DO WITH ASP.NET?


­ Easily and quickly create simple Web applications.
­ Generate dynamic Web content
­ Client-side scripting for validation
­ Access COM components to extend functionality

WHAT IS AN ASP.NET FILE?


­ An ASP.NET file is just the same as an HTML file
­ An ASP.NET file can contain HTML, XML, and scripts
­ Scripts in an ASP.NET file are executed on the server
­ An ASP.NET file has the file extension ".aspx"

HOW DOES ASP.NET WORK?


­ When a browser requests an HTML file, the server returns the file.
­ When a browser requests an ASP.NET file, IIS passes the request to the ASP
.NET engine on the server.
­ The ASP.NET engine reads the file, line by line, and executes the scripts in the
file.
­ Finally, the ASP.NET file is returned to the browser as plain HTML.

Advantages of ASP .NET


1. Separation of code from HTML
 To make a clean sweep, with ASP.NET you have the ability to completely
separate layout and business logic.
 This makes it much easier for teams of programmers and designers to
collaborate efficiently.
2. Support for compiled languages
 Developer can use VB.NET and access features such as strong typing and
object oriented programming.
 Using compiled languages also means that ASP.NET pages do not suffer the
performance penalties associated with interpreted code ASP.NET pages are
precompiled to byte-code and Just In Time (IT) compiled when first
requested. Subsequent requests are directed to the fully compiled code,
which is cached until the source changes.
3. Use services provided by the .NET Framework

Dr. Priyanka Mehta (Assist. Prof.) Page 10


ASP .NET – 505 (TYBCA Sem – 5)

 The .NET Framework provides class libraries that can be used by your
application.
 Some of the key classes help you with input/output, access to operating
system services, data access, or even debugging. We will go into more detail
on some of them in this module.
4. Graphical Development Environment
 Visual Studio .NET provides a very rich development environment for Web
developers. You can drag and drop controls and set properties.
5. State management
 To refer to the problems mentioned before, ASP.NET provides solutions for
session and application state management.
 State information can, for example, be kept in memory or stored in a
database.
6. Update files while the server is running
 Components of your application can be updated while the server is online and
clients are connected.
7. XML-Based Configuration Files
 Configuration settings in ASP.NET are stored in XML files that you can easily
read and edit.
 You can also easily copy these to another server, along with the other files
that comprise your application.
8. Security
 With built in Windows authentication and per-application configuration, you
can be assured that your applications are secure.

Difference between ASP and ASP.NET

Sr. Key ASP ASP.NET


No.

1 Definition ASP or also popularly known as ASP.NET, on the other hand, is


Classic ASP developed by a server-side web framework,
Microsoft is first Server-side open-source, which is designed
scripting engine which is used for for the generation of dynamic
dynamic generation of web pages. web pages.

2 Language ASP is interpreted language that On other hand ASP.NET is the


type means the compiler interpret the compiled language and treated
compiling code. Also ASP is as fully object oriented

Dr. Priyanka Mehta (Assist. Prof.) Page 11


ASP .NET – 505 (TYBCA Sem – 5)

Sr. Key ASP ASP.NET


No.

treated as partially object oriented language.


language.

3 Database In order to connect with database While on other hand ASP.NET


Interaction ASP language uses ADO (ActiveX uses ADO.NET to connect and
Data Objects). work with database.

4 Inheritance As mentioned in above point ASP On other hand ASP.NET has


is partial object oriented language inheritance support in its code.
hence it doesn’t have the concept
of inheritance.

5 Built-in Maximum four in-built classes i.e. On other hand ASP.NET has
Class. Request, Response, Session and more than 2000 in-built
Application are present in ASP. classes.

6 Error Error handling support in ASP is On other hand ASP.NET has


Handing less efficient as compared to that in more efficient error handling
ASP.NET. support as compared to that in
ASP.

1.3. Compile Code


­ Two models for coding web pages and web services:
1) Inline code:
 . This model is the closest to traditional ASP.
 All the code and HTML is stored in a single.aspx file.

Advantages of Inline code:

Advantages of the single-file page model include the following:

 In pages where there is not very much code, the convenience of keeping
the code and markup in the same file.

Dr. Priyanka Mehta (Assist. Prof.) Page 12


ASP .NET – 505 (TYBCA Sem – 5)

 Pages written using the single-file model are slightly easier to deploy or to
another programmer because there is only one file.
 Single-file page is easier to rename.
 Number of file in the project is less.

2) Code-behind:
 This model separates each ASP.NET web page into two files: an .aspx
markup file with the HTML and control tags, and a .cs or. vb code file with the
source code for the page.

Advantages of Inline code:

Advantages of the code-behind model include the following:

 Code-behind pages offer a clean separation of the markup and code.


 It is practical to have a designer working on the markup while a
programmer writes code.
 Code can be reused for multiple pages.

1.4. Event Driven Programming


­ Any identifiable occurrence that has significance for system hardware or software
is called the Event. So we can say that, Event is the action or the occurrence that
is detected by the program. User-generated events include keystrokes and
mouse clicks, among a wide variety of other possibilities.
­ There are two programming approaches: Linear and Event Driven
­ Linear programs move in a linear fashion, from step 1 to step 2 and so on, to the
end of all the steps. Flow control structures within the code (such as
loops, if statements, or function or subroutine calls) may redirect the flow of the
program, but essentially, once program execution begins, it runs its course
unaffected by anything the user or system may do.
­ In contrast, the programming approach, which response to the event or handle
the event is called Event Driven Programming. These events may be generated
by user action or by system. Windows operating system is the Event Driven
Program (EDP).

Dr. Priyanka Mehta (Assist. Prof.) Page 13


ASP .NET – 505 (TYBCA Sem – 5)

1.5. Page Life Cycle

1.5.1. Phases of Page Life Cycle


1) Page Request
 As we have seen in above diagram, the page request occurs before the
page life cycle starts. It checks that the page needs to be parsed and
compiled or not.
2) Start
 In this phase, several properties such as Response, Request, IsPostBack
and UICulture are set. Along with, it checks that the request is the
postback (the contents of the form are Posted Back to itself) request or
not.
3) Page Initialization
 During this phase, the controls are available on the page and its ID
property is set then themes are applied. If the request is the postback
request, the postback data are not loaded and the values of the controls
not restored from the ViewState
4) Load
 Now in this phase, the request is the postback request, the postback data
is loaded and the values of the controls are not restored from the
ViewState
5) Validation
 In this phase, if the validation controls are present on the page then its
Validate() method is called, which in turn set the IsValid property of the
controls and page.
6) Postback event handling
 If the event handlers of the Postblack are need to be called, then they are
called during this phase.
7) Rendering
 Prior to this phase, the View State for page and controls are saved.
During rendering phase Render() method of the controls and page is
called which gives the output to the OutputStream of the Response
property.
8) Unload
 The page comes in this phase, when there is a need to dispose the page
as it might not be further needed. Request and Response properties of the
page are also unloaded.

Dr. Priyanka Mehta (Assist. Prof.) Page 14


ASP .NET – 505 (TYBCA Sem – 5)

1.5.2. Page Events


1) Page Preinit()
 This event is used for the following purpose.
 Check the IsPostBack property to determine whether the page is being
processed first time.
 Create or re-create dynamic controls.
 Set a master page dynamically.
 Set the Theme property dynamically.
 Read or set profile property values.

2) Page_Init()
 It is executed after the Prelnit() event. It is used to retrieve or initialize
control properties.

3) Page Preload()
 Prior to this event, the ViewState data and PostBack data are restored to
the controls. This event is used if we want to do some task before load
event is executed.
4) Page Load()
 It calls the Load event of the page as well as each control on the page.
This event is use to set the properties of the controls and it can also be
used to establish database connection.
5) Control events
 They are useful to handle the events of the controls. E.g. click event of the
Button.

6) Page_PreRender()

 It is executed for each control on the page. It is used to make final


changes to the page and its controls.
 PreRender is the event that takes place before the HTML for a given page
is generated and sent to the browser.

7) Page_Unload()

 It is executed for each control and then for the page. So we can say that it
is useful for the final cleanup such as closing the connection, closing files,
completing log etc.

1.6. Object Oriented Concepts


­ Object Oriented Programming (OOP) is one of the most popular programming
languages. In the class-based object-oriented programming paradigm, "object"
refers to a particular instance of a class where the object can be a combination of
variables, functions, and data structures.

Dr. Priyanka Mehta (Assist. Prof.) Page 15


ASP .NET – 505 (TYBCA Sem – 5)

­ Object Oriented programming is a programming style which is associated with


the concepts like class, object, Inheritance, Encapsulation, Abstraction,
Polymorphism.

1.6.1. Object
 They are the basic runtime entities having attributes (data type) and
behaviors (functions).
(functions). They are the variables of the class. It is said to be the
instance of the class.
 It is a real time entity.

1.6.2. Class
 The class is a template through which we can create an object.
 Class is a data structure that contains data members (constants files, events),
member function methods, properties, constructor, destructor, indexers and
nested type.
 It is a collection objects.
 Basically,
1) It is a user defined data type.
2) It is a referenc
reference type.
3) Infect class is a tag or template for object.

1.6.3. Encapsulation
 The process of uniting data members and methods in a single unit is called
Encapsulation. In other words, to combine data and function into a single
logical unit is known as encapsulation.
 When using Data Encapsulation, data is not accessed directly;
directly it is only
accessible through the functions present inside the class. Data Encapsulation
enables the important concept of data hiding.

Dr. Priyanka Mehta (Assist. Prof.) Page 16


ASP .NET – 505 (TYBCA Sem – 5)

 Protecting data from access by unauthorized function (external function) is


called data hiding.

1.6.4. Inheritance
 It is the process by which object of one class acquire the properties, i.e. data /
attributes of object, of another class. That means inheritance is the process
of forming a new class from an existing class or base class.
 The base class is also known as parent class or super class, the new class
created from base class is called derived class. Derived class is also known
as a child class or sub class. Inheritance helps in reducing the overall code
size of the program, which is an important concept in object-oriented
programming.
 This is important because it supports hierarchical classification. In object
oriented programming the concepts of inheritance provide the idea of
reusability. This means that we can add additional features to an existing
class without modifying it.
 This is possible by deriving a new class from the existing one. The new class
has the combine features of both the classes.
 To inherit the class Inherits keyword is used with derived class.

1.6.5. Abstraction
 It is a mechanism of representing essential features without including
background details.
 Data Abstraction increases the power of programming language by creating
user defined data types. Data Abstraction also represents the needed
information in the program without presenting the details.
 When the classes use the concept of data abstraction, they are also known
as Abstract DataTypes (ADT).

1.6.6. Polymorphism
 It is the Greek word, poly means many and morphism means forms i.e. one
name many forms.
 The ability of functions and operators to act in different ways on different data
type is called polymorphism.
 To use one function name for many different purposes is known as function
overloading. So Overloading is one type of Polymorphism. It allows an
object to have different meanings, depending on its context.
 Polymorphism allows routines to use variables of different types whenever
required. To implement function overloading, Overloads keyword is used.
 There are two ways to implement polymorphism
1) Static Polymorphism (compile time)
2) Dynamic Polymorphism (run time)

Dr. Priyanka Mehta (Assist. Prof.) Page 17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy