ankitweblogic logo
W e b t u t o r i a l s

ASP Tutorial


ASP.NET Introduction

ASP.NET Web Forms

Standard Controls

Label Control

TextBox Control

Image Control

Button Controls

Redirecting User

Using HyperLinks

RadioButton Control


CheckBox Control

CheckBoxList Control


ListBox Control

ImageMap Control

Master Page

View State

Event-Driven Programming


ASP.NET Page Structure

Visibility of Controls

Formatting Controls

Applying CSS

Dynamic CSS

Using Style Class

Themes and Skins

Panel Control

PlaceHolder Control

AdRotator Control

Calendar Control

Validation Controls

Page Navigation

User Control

Separating Code-Presentation

Overview of ADO.NET

Data Binding

DataBinding List Control

Introduction to ASP.NET

Microsoft provides the .NET Framework SDK (Software Development Kit) as a complete development toolkit for developing console, windows and web applications. The Microsoft Visual Studio which is powerful integrated development environment, support C#.Net, Visual Basic.NET, Jscript.NET, J#.Net etc.

.NET Framework
The .NET Framework consists of huge libraries that can be used in our application. The .NET framework includes the Common Language Runtime (CLR) which is responsible for maintaining the execution of all applications developed using .NET Library.

.NET Framework Class Library
In ASP, we can access only 5 major objects i.e. Request, Response, Application, Session and Server. In ASP.NET, we can access over 6,000 classes.

The CLR is responsible for executing your application code. Source code is never compiled directly into machine code. Instead, the compiler converts your code into a special language named Microsoft Intermediate Language (MSIL). MSIL is not CPU-specific. It is a low-level and platform-independent language. When your application actually executes, the MSIL code is converted into machine code by the JITTER (the Just-In-Time compiler).
Normally, your entire application is not compiled from MSIL into machine code. Instead, only the methods actually called during execution are compiled.
The runtime environment of the .NET Framework is known as the Common Language Runtime (CLR) because it is common to all .NET applications and can be used to execute any .NET application. Thus, CLR provides cross-language interoperability to .NET application.
The CLR looks after our applications, by managing memory, handling security, allowing cross language debugging and so on.

Garbage Collection
One of the most important features of the managed code is the concept of garbage collection. This is the .NET method of making sure that the memory used by an application is freed up completely when the application is no longer in use. Prior to .NET this is the responsibility of programmers, and a few simple errors in code could result in large blocks of memory disappear. This usually slow down the performance of your computer followed by the system crash.
.NET garbage collection works by inspecting the memory of your computer so often, and removing anything from it that is no longer needed. There is no set time frame for this, it may happen thousands of time per second or once every few seconds.

The C# code that compiles into MSIL needn’t be contained in a single file. It is possible to split application code across multiple source code files, which are then compiled together into a single assembly. This process is known as linking. You can separate out logically related code into an individual file, such that it can be worked independently. This also makes it much easier for a team of developers to divide the programming burden.

Benefits of .NET Framework in ASP.NET
i. Support for web-based user interfaces:
ii. Data Accessibility: The .NET Framework provides a new set of data access objects called ADO.NET, which can be used to access any kind of data located anywhere on the internet.
iii. Scalability, Availability and Robustness: The .NET Framework can automatically detect errors and manage restarting of applications and components. It can gracefully recover from crashes, deadlocks and memory leaks. The result is that badly behaved applications cannot bring the server down and the applications always appear to be available to genuine users.

ASP.NET is the latest version of Active Server Pages (ASP). ASP.NET is part of the Microsoft .NET Framework. ASP.NET is a Microsoft’s server-side web technology for building dynamic, interactive and database-driven web sites.
ASP is one of the most popular technology for developing web applications and sites. ASP is a mix of HTML and Server-side scripting to generate dynamic and interactive web pages and applications. It supports COM components and even COM+ runtime services.

Disadvantages of ASP
i. Poor Reusability – ASP pages are interpreted and executed on the Web server, line-by-line, from top to bottom. Each page is therefore written in a sequential manner to meet specific objectives, which makes it difficult to re-use the page in another ASP application.
ii. Supports only scripting languages – Scripting languages are limited in functionality when compared to programming languages. Most developers who have worked with programming languages wish to use the full functionality of a programming language to develop complex Web applications. Moreover, scripting languages are interpreted and not compiled. This affects performance as the ASP scripts must be parsed and executed every time a request is made.
iii. No separation of code and presentation – Scripts in ASP pages are mixed with the HTML code and executed in-line with it. This makes it very difficult to read and understand an ASP application written by somebody else. So, project development, involving multiple team members and project maintenance are both made difficult.
iv. Poor support for state management – ASP does not provide built-in support for retaining the state of HTML forms. Developers have to write additional code to save the data entered by users in form fields during post-backs and restore the data in the form before returning the form to the users.
v. Poor support for multiple browsers – Different browsers support ASP to different extents. In order to support multiple browsers, developers have to explicitly write different versions of the code.
vi. Platform-dependence – ASP is limited to the Windows platform though there are some versions of ASP available for other platforms also. This factor restricts the reach of Web applications on the Internet.

ASP.NET attempts to overcome these drawbacks and make web applications easy and efficient
Advantages of ASP.NET
i. Support for .NET Framework – ASP.NET is a part of the .NET Framework. The .NET Framework provides almost 13,000 classes that can be used in ASP.NET pages.
ii. Support for programming languages.
iii. Platform Independant.
iv. Support for separation of code and presentation.
v. Web services
vi. Client platform Independence.

Note: By default, files with the extension, .asp are mapped by IIS to asp.dll and files with the extension .aspx are mapped to aspnet_isapi.dll.

ASP.NET Namespaces
Classes are organized into a hierarchy of namespaces. A namespace is a logical grouping of classes. For instance, the system.web namespace contains basic classes for creating web applications. System namespace is the root of the hierarchy.
Some of the namespaces in the .NET Framework class library are available in ASP.NET page by default. Some commonly used classes in ASP.NET applications are:
• System: Contains all the base data types. Also contains classes for working with random numbers and dates and times.
• System.Collections: Contains classes for working with standard collection types such as hash tables and array lists.
• System.Text: Contains classes for encoding, decoding and manipulating contents of strings.
• System.Web: Contains the basic classes for working with the World Wide Web, including classes for representing browser requests and server responses.
• System.Web.Caching: Contains classes used to cache page contents and perform custom caching operations.
• System.Web.Security: Contains classes for implementing authentication and authorization such as Passport authentication.
• System.Web.SessionState: Contains classes for implementing session state.
• System.Web.UI: Contains classes used to build the user interface of ASP.NET pages.
• System.Web.UI.HTMLControls: Contains classes for HTML controls.
• System.Web.UI.WebControls: Contains classes for Web controls.

.NET Framework-Compatible Languages
VB.NET is the default language for ASP.NET pages. ASP.NET supports several other languages (both Microsoft and non-Microsoft products) that support the .NET runtime environment. These include C#, Visual C++, JScript.NET and Python, SmallTalk, Eiffel, and COBOL.
ASP.NET pages are compiled and therefore execute quickly. They are always compiled into an intermediate-level language called Microsoft Intermediate Language (MSIL). The first time a user requests your ASP.NET page, the page is compiled into a .NET class (in the MSIL format). This class file is saved in a directory known as Temporary ASP.NET Files on the server. When the same page is requested again, the corresponding class file is executed. The class file is compiled with the .NET Framework Just-in-Time (JIT) compiler into native machine code and executed.

Such a two-step compilation method offers the following advantages:
• Compiling and caching the source code in an intermediate format reduces the response time as compared to interpreting and executing the source code at runtime.
• The IL code can be executed on any platform, as it is in a binary format.

Characteristics of ASP.NET
1. ASP.NET Web Forms Pages
2. ASP.NET Controls
3. Cross-Language Support.
4. Event-Driven Programming Model
5. Data Access: ASP.NET supports ADO.NET provided by the .NET Framework.
6. Session State Management
7. Deployment: ASP.NET applications can be deployed by simply copying the files to the appropriate directory on the Web server.
8. Error handling, Debugging, and Tracing.
9. Security Management: To secure an ASP.NET application, you must perform the three fundamental functions, authentication, authorization, and impersonation.
o Authentication: such as name and password are validated.
o Authorization: It limits access rights by granting or denying specific permissions to an authenticated identity.
o Impersonation: It enables the ASP.NET application to execute in the context of an authenticated or anonymous user when the request is passed to the application from IIS. Access is then granted or denied based on the impersonated identity.
10. Caching.