0% found this document useful (0 votes)
13 views15 pages

Aspunit 1

The document provides an overview of ASP.NET, detailing its framework, design features, and evolution. It explains the architecture of ASP.NET, its advantages over client-side technologies, and the structure of an ASP.NET page, including directives and controls. Additionally, it highlights the benefits of using ASP.NET for web application development, such as simplified deployment, improved performance, and enhanced security features.

Uploaded by

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

Aspunit 1

The document provides an overview of ASP.NET, detailing its framework, design features, and evolution. It explains the architecture of ASP.NET, its advantages over client-side technologies, and the structure of an ASP.NET page, including directives and controls. Additionally, it highlights the benefits of using ASP.NET for web application development, such as simplified deployment, improved performance, and enhanced security features.

Uploaded by

sakthi priya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ASP.

NET - UNIT 1
SYLLABUS :
UNIT I : [Link] Basics Introduction to [Link]: .NET Framework (CLR, CLI,
BCL), [Link] Basics, [Link] Page Structure, Page Life Cycle. Controls: HTML Server
Controls, Web Server Controls, Web User Controls, Validation Controls, Custom Web
Controls.

1.1 INTRODUCTION TO .NET Framework


The .NET Framework is a software framework developed by Microsoft. The .NET runs
on Microsoft Windows. It provides language interoperability and can run across several
programming languages and platforms. Programs written for the .NET Framework execute
in a software environment, known as the Common Language Runtime (CLR). CLR is an
application virtual machine that provides services such as security, memory management,
and exception handling. The class libraries and the CLR together constitute the .NET
Framework.
The .NET Framework's Base Class Library provides user interface, data access,
database connectivity, cryptography, web application development, numeric algorithms,
and network communications.

1.2 DESIGN FEATURES OF .NET


 Interoperability .NET Framework provides access to newer and older programs
that execute outside the .NET environment. Access to COM components is provided
in the [Link].
 Common Language Runtime engineCommon Language Runtime (CLR) serves as the
execution engine of the .NET Framework. All .NET programs execute under the
supervision of the CLR, guaranteeing certain properties and behaviors in the areas of
memory management, security and exception handling.
 Language independence The .NET Framework has Common Type System(CTS). CTS is
used to support all datatypes and programming constructs supported by the
CLR Because of CTS, the .NET Framework supports the exchange of types and object
instances between libraries and applications written using any conforming .NET
language.
 Base Class Library The Base Class Library (BCL), is part of the Framework Class
Library (FCL). It is a library of functionality available to all languages using the .NET
Framework. The BCL provides classes that encapsulate a number of common
functions, including file reading and writing, graphic rendering, database interaction,
XML document manipulation, and so on. It consists of classes, interfaces of reusable
types that integrates with CLR.
 Simplified deployment The .NET Framework includes design features and tools
which help manage the installation of computer software to ensure it does not
interfere with previously installed software.
 Security .NET provides a common security model for all applications. It
eliminates the vulnerabilities, such as buffer overflows, which have been exploited
by malicious software. Additionally,
 Portability .NET framework is platform independent and cross-platform
implementations are available for other operating systems.

1.3 EVOLUTION OF .NET

Framework Versions /Tools used Features

.NET Framework First version of .NET Framework.


1.0
(February 2002)

.NET Framework C# Version: 1.2  [Link] and [Link] updates


1.1
 Side by side execution
(April 2003)
CLR Version: 1.1  .NET Compact framework
 Secure coding guideline
 Information about application
deployment

.NET Framework C# Version: 2.0  64-bit platform support


2.0
 Access Control List Support
(November 2003)
 Data Protection APIs
CLR Version: 2.0
 Detecting changes in network
connectivity
Development
 FTP Support
Tool :Visual Studio 2005
 Web Services

.NET Framework C# Version: 3.0  Windows Communication


3.0 Foundation
CLR Ver: 2.0
(November 2006)
 Windows Presentation Foundation
Dev Tool: Visual Studio
2005  Windows Forms

.NET Framework C# Version: 3.0  [Link] Ajax enabled Websites


3.5
 LINQ
(November 2007)
 Dynamic DataCollections
CLR Version: 2.0
 Time Zone Improvements
 Cryptography Enhancements
Development
Tool :Visual Studio 2008
 Web Service interoperability

.NET Framework C# Version: 4.0  Expanded Base Class


4.0
 Cross-Platform Development
(April 2010) with portable class library
CLR Version: 4
 Dynamic Language Runtime
Development
 Parallel Computing
Tool :Visual Studio 2010

.NET Framework C# Version: 6.0  Compilation Using .NET Native


4.6 CLR Version: 4.0
 [Link] Core 5
Development
(July 2015)
Tool :Visual Studio 2015  HTTP/2 Support
 64-bit JIT Compiler for managed
code
 SSL Support

.NET Framework C# Version:  Enhanced cryptography with


4.7 CLR Version: 4.0 elliptic curve cryptography.
Development
(April 2017)  Support for High-DPI awareness
Tool :Visual Studio 2017
support in Windows Forms.
 More support for touch and
stylus in Windows Presentation
Foundation.

.NET Framework C# Version:  Runtime – JIT improvements.


4.8 CLR Version: 4.0
 Runtime – Antimalware
Development
(April 2019) Scanning.
Tool :Visual Studio 2019
 Windows Forms – Accessibility
Enhancements.

Table 1 : Evolution of .NET (Reference Wikipedia)

1.4 COMMON LANGUAGE INFRASTRUCTURE (CLI)


Common Language Infrastructure (CLI)provides a language-neutral platform for
application development and execution, including functions for Exception handling, Garbage
Collection, security, and interoperability.
By using the features of the .NET Framework within the scope of the CLI, the
functionality will be available across all the languages supported by the framework.
Microsoft's implementation of the CLI is called the Common Language Runtime, or CLR.
The CIL code is housed in CLI assemblies. CLI assemblies are stored in the Portable
Executable (PE) format for all DLL and EXE files.
The complete name of an assembly contains its simple text name, version number,
culture, and public key token. Assemblies are considered equivalent if they share the same
complete name, excluding the revision of the version number.

1.5 . [Link]
[Link], the next version of ASP, is a programming framework used to create enterprise-
class Web Applications. These applications are accessible on a global basis leading to
efficient information management.

1.6 Advantages of using [Link]


 [Link] reduces the amount of code required to build large applications [Link]
applications runs faster and counters large volumes of users without performance
problems.
 [Link] makes development simpler and easier to maintain with an event-driven,
server-side programming model
 [Link] pages are easy to write and maintain because the source code and HTML
are together.
 The source code which is executed in the server is compiled the first time the page is
requested. Execution is fast as the Web Server compiles the page the first time it is
requested. The server saves the compiled version of the page for use next time the
page is requested .
 The HTML produced by the [Link] page is sent back to the browser. The
application source code is not sent and is not easily stolen .
 [Link] facilitates for easy deployment. There is no need to register components
because the configuration information is built-in.
 The Web server continuously monitors the pages, components and applications
running on it. If it notices memory leaks, infinite loops, other illegal software or
activities, it seamlessly kills those activities and restarts itself.
 [Link] validates information (validation controls) entered by the user without
writing a single line of code.
 [Link] works with ADO .NET for connecting to databases and data-binding.

1.7 DIFFERENCES BETWEEN [Link] AND CLIENT-SIDE TECHNOLOGIES


Client-side refers to browser and the machine running the browser. Server-side refers to
Web server.
Client-Side Scripting JavaScript and VBScript are generally used for Client-side
scripting and it is executed in the browser after the page is loaded. Both, HTML and the
script are together in the same file and the script is downloaded as part of the page. A
client-side script runs only on a browser that supports scripting and specifically the scripting
language that is used. Since the script is in the same file as the HTML and as it executes on
the machine you use, the page may take longer time to download.
Server-Side Scripting [Link] is purely server-side technology. [Link] code executes on
the server before it is sent to the browser. The code that is sent back to the browser is pure
HTML and not [Link] code. Like client-side scripting, [Link] code is written alongside
HTML. Unlike client-side scripting, [Link] code is executed in server and not in the
browser. The script that is present along with HTML is not sent back to the browser and that
prevents others from stealing the code.

1.8 FEATURES OF [Link]


 ASPX,ASP Up gradation of ASP to ASPX is not required it supports side by side
execution and hence a request can be given from ASP to ASPX and vice versa.
 Simplified Programming Model [Link] is a technology which can be
implemented using any dot net language such as [Link],C# etc and hence there is no
requirement of HTML, JavaScript or VBScript to implement [Link]
 Simplified deployment [Link] supports setup and deployment and hence the
web app can be defined with a web set up project which can be easily deployed on
to the web server. In for ASP CUTE FTP is used for deploying, it is required to upload
manually.
 Better Performance Since ASPX pages are complier based the performance of the
web application will be faster than the ASP pages (as they are interpreter based)
 Caching It is a process of maintaining the result or output of a web page
temporarily for some period of time .ASP supports Client Side caching where
as [Link] supports both client side and server side.
 Security In ASP security is done by IIS or writing the code manually. In [Link] it
is defined with built in security features such as
* windows authentication * Forms Authentication
* Passport Authentication * Custom Authentication
 More powerful data access [Link] supports ADO and [Link] as its database
connectivity model which will be implemented using the most Powerful OOP’S
languages like [Link] and C# and hence the database access using ASPX pages will
be very powerful.
 Web services It is a code which will be published on the web which can be used by
any applications written using any language for an platform or device.
 Better session Management Session Management in [Link] can be maintained
using the database and cookieless sessions are also supported. It also supports
enabling and disabling of session info within a web application.
 Simplified Form Validations [Link] provides validation controls using which any
type of client side validations are performed without writing any code.

1.9 ARCHITECTURE OF [Link]


A web page is in 2 parts
1} Designing part (HTML Content,Flash,Dreamweaver etc)
2} logic Part (sub programs and event procedures and it has also your database
interaction)
[Link] supports 2 techniques for creating web page
1) In Page Technique when you place design part code and logic part code with in a
single file called as ASPX then it is called as inPage Technique.
2) Code Behind Technique when design part code is represented with in ASPX file
and logic part code is represented with in dll file then it is called as code behind
technique.

ASP Supports only In Page technique.

DLL file is not a readable file


 Inet_info.exe  identifies the request and submits the request to the
aspnet_isapi.dll.
 Aspnet_isapi.dll  is a script engine which process the .aspx page
 Then the script engine will submit the request to the [Link] runtime env.
 After verifying all the security issues of both [Link] and [Link] then an
AppDomain will be defined for the request and after processing the request the
response will be given to the client as HTTP response.
 [Link]  it is used to maintain the complete configuration details of all the
web applications registered on to the web server of [Link]
 [Link]  It is used to maintain the config details about a single web application.
o Configuration details includes security, database connectivity, state
management, trace details of the web application, authentication and
authorization of the applications and globalizations.
 AppDomain: All windows applications run inside a process and these process own
resources such as memory and kernel objects. All the applications are run on high
isolation mode to work safely. The disadvantage of this is memory resources are
blocked. So to achieve this in a single process all the applications should be made to
run which is good to an extent. In .net the code verification feature takes care that
the code is safe to run, so [Link] each application runs its own application domain.
 HTTPHandlers: [Link] is built on extensible architecture known as HTTP runtime.
This is responsible for handling the requests and sending the response. IS supports a
low level API known as ISAPI. [Link] implements a similar concept with HTTP
handlers. A request is assigned to [Link] from IIS then [Link] examines entries in
the <httphandlers> section based on the extension of the request to determine
which handler the request should be send to.

1.10 The Structure of an [Link] Page


The important elements of an [Link] page are:
 Directives
 Code declaration blocks
 [Link] controls
 Code render blocks
 Server-side comments
 Server-side include directives
 Literal text and HTML tags
Directives A directive controls the compilation of [Link]. The directive begins with the
characters <%@ and the end of a directive is marked with the characters %>.These
instructions include registering a custom control, page language etc. It describes how
the .aspx pages (web forms) or .ascx pages (user controls) are processed by the .net
framework.
A directive can appear anywhere within a page. By convention, however, a directive
typically appears at the top of an [Link] page.
There are several types of directives that can be added to an [Link] page. Two of
the most useful types are page and import directives.
Page Directives A page directive is used to specify the default programming language
for a page. Page directives can also be used to enable tracing and debugging for a page.
To change the default programming language of an [Link] page from Visual Basic to C#,
for example, you would use the following page directive:
<%@ Page Language="C#" %>
NOTE : The keyword Page in a page directive is optional. The following two directives
are equivalent: <%@ Page Language="C#" %>
<%@ Language="C#" %>
TRACE DIRECTIVE : If Trace directive is enabled, for a page, additional information about the
execution of the page is displayed along with the content of the page. Tracing can be
enabled for a page by including the following directive:
<%@ Page Trace="True" %>
After enabling tracing for a page, trace messages can be displayed by using two methods of
the Trace class: Write() and Warn(). Either of these methods can be used to display custom
message in the trace information displayed at the bottom of the page. The only difference
between the two methods is that the former method displays messages in black text, and
the latter method displays messages in red text, which is easier to see.
DEBUG DIRECTIVE To enable runtime error messages to be displayed on a page,
the Debugdirective is used. To display errors in [Link] page, the following directive is
included:
<%@ Page Debug="True" %>
If this directive is included, when an error is encountered while processing the page, the
error is displayed. In most cases, we can view source code for the exact statement that
generated the error.
To enable both tracing and debugging for a page, combine the directives like this.
<%@ Page Debug="True" Trace="True" %>
IMPORT DIRECTIVES By default, only certain namespaces are automatically imported
into [Link] page. Inorder to refer to a class that isn't a member of one of the default
namespaces, the namespace must be explicitly imported or t use the fully qualified name of
the class.
For example, to send an email from an [Link] page by using the Send method of
the SmtpMailclass, SmtpMail class is to added as an Import directive. The SmtpMail class is
contained in the [Link] namespace. This is not a default namespace imported
into an [Link] page.

@ assembly The @assembly directive attaches assemblies to the page or an [Link] user
control thereby all the assembly classes and interfaces are available to the class. This
directive supports the two attributes name and src. The name attribute defines the
assembly name and the src attribute defines the source of the assembly.
@ control Defines control-specific attributes used by the [Link] page parser and
compiler and can be included only in .ascx files (user controls).
@ implements The @implements directive gets the [Link] pages to implement .net
framework interfaces. This directive only supports a single attribute interface.
@ master Identifies a page as a master page and defines attributes used by the [Link]
page parser and compiler and can be included only in .master files.
@ page The @page directive enables you to specify attributes and values for an
[Link] page to be used when the page is parsed and compiled. Every .aspx files should
include this @page directive to execute. There are many attributes belong to this directive.
@ reference Links a page, user control, or com control to the current page or user control
declaratively.
@ register Associates aliases with namespaces and classes, which allow user controls and
custom server controls to be rendered when included in a requested page or user control.
CODE DECLARATION BLOCKS A code declaration block contains all the application logic for
your [Link] page and all the global variable declarations, subroutines, and functions. It
must appear within a <Script Runat="Server"> tag.
Codefile specifies a path to the referenced code-behind file for the page. Inherits defines the
name of the class from which to inherit. This can be any class derived from the page class
1.11 Page Life Cycle Events
 Page_Init This is fired when the page is initialized
 Page_Load This is fired when the page is loaded.
The difference between Page_Init and Page_load is that the controls are
guaranteed to be fully loaded in the Page_load.The controls are accessible in the
Page_Init event,but the ViewState is not loaded,so controls will have their
default values,rather than any values set during the postback.
 Control_Event This is fired if a control triggered the page to be reloaded (such as a
button)
 Page_unload This is fired when the page is unloaded from the memory

1.12. TYPES OF CONTROLS IN [Link]


1.12.1 HTML Server Controls
HTML elements in [Link] files are, by default, treated as text. To make these elements
programmable, add a runat="server" attribute to the HTML element. This attribute indicates
that the element should be treated as a server control.
Note: All HTML server controls must be within a <form> tag with the runat="server"
attribute!, [Link] requires that all HTML elements must be properly closed and properly
nested.
SYNTAX
<INPUT TYPE=TEXT RUNAT=SERVER>

HTML Server Control Description

HtmlAnchor Controls an <a> HTML tag

HtmlButton Controls a <button> HTML tag

HtmlForm Controls a <form> HTML tag

HtmlImage Controls an <image> HTML tag

HtmlInputButton Controls <input type="button">, <input


type="submit">, and <input
type="reset"> HTML tags

HtmlInputCheckBox Controls an <input type="checkbox">


HTML tag

HtmlInputFile Controls an <input type="file"> HTML tag


HtmlInputHidden Controls an <input type="hidden"> HTML
tag

HtmlInputImage Controls an <input type="image"> HTML


tag

HtmlInputRadioButton Controls an <input type="radio"> HTML


tag

HtmlInputText Controls <input type="text"> and <input


type="password"> HTML tags

HtmlSelect Controls a <select> HTML tag

HtmlTable Controls a <table> HTML tag

HtmlTableCell Controls <td>and <th> HTML tags

HtmlTableRow Controls a <tr> HTML tag

HtmlTextArea Controls a <textarea> HTML tag

1.12.2 WEBSERVER CONTROLS


Web server controls are special [Link] tags understood by the server. Like HTML
server controls, Web server controls are also created on the server and they require a
runat="server" attribute to work.

Standard Controls List Controls Validation Controls Data bound Misc Controls
Controls

 label  Radio Button List 1. Required field  Data Grid  Crystal


Validator Report
 Textbox  Check Box List  Data List
Viewer
2. Range Validator
 Button  Dropdown List  Repeater control
3. Compare Validator
 Link Button  List Box
4. Regular Expression
 Image Button Validator
 Calendar 5. Custom Validator

 AdRotator 6. Validation
Summary
 Panel
 Place Holder
 Table
 Literal Control
 Radio Button
 Check Box
 XML

Common Syntax for any web server control


 <asp:controltype id=“name of the control” runat=“server”
----------------
----------------
//additional properties
></asp:controltype>

 In order to set or get the value from any standard control text property should be
used.
Eg: <asp:label id=“lb1” runat=“server” text=“user name”></asp:label>
<asp:button id=“lb1” runat=“server” text=“Login” />

Web Server Description


Control

AdRotator Displays a sequence of images

Button Displays a push button

Calendar Displays a calendar

CheckBox Displays a check box

CheckBoxList Creates a multi-selection check


box group

DataGrid Displays fields of a data source in


a grid

DataList Displays items from a data source


by using templates

DropDownList Creates a drop-down list


HyperLink Creates a hyperlink

Image Displays an image

ImageButton Displays a clickable image

Label Displays static content which is


programmable

LinkButton Creates a hyperlink button

ListBox Creates a single- or multi-


selection drop-down list

ListItem Creates an item in a list

Literal Displays static content which is


programmable

Panel Provides a container for other


controls

PlaceHolder Reserves space for controls


added by code

RadioButton Creates a radio button

RadioButtonList Creates a group of radio buttons

BulletedList Creates a list in bullet format

Repeater Displays a repeated list of items


bound to the control

Style Sets the style of controls

Table Creates a table

TableCell Creates a table cell

TableRow Creates a table row

TextBox Creates a text box

Validation Controls in [Link]


An important aspect of creating [Link] Web pages for user input is to be able to
check that the information users enter is valid. [Link] provides a set of validation
controls that provide an easy-to-use but powerful way to check for errors and, if
necessary, display messages to the user.

There are six types of validation controls in [Link]

1. RequiredFieldValidation Control
2. CompareValidator Control
3. RangeValidator Control
4. RegularExpressionValidator Control
5. CustomValidator Control
6. ValidationSummary

The below table describes the controls and their work,


Validation Control Description

RequiredFieldValidation Makes an input control a required field

Compares the value of one input control to the value of


CompareValidator
another input control or to a fixed value

Checks that the user enters a value that falls between


RangeValidator
two values

Ensures that the value of an input control matches a


RegularExpressionValidator
specified pattern

Allows you to write a method to handle the validation of


CustomValidator
the value entered

Displays a report of all validation errors occurred in a


ValidationSummary
Web page

All validation controls are rendered in form as <span> (label are referred as <span>
on client by server)
Important points for validation controls

 ControlToValidate property is mandatory to all validate controls.


 One validation control will validate only one input control but multiple validate
control can be assigned to a input control.

Validation Properties
Usually, Validation is invoked in response to user actions like clicking submit button
or entering data. Suppose, you wish to perform validation on page when user clicks
submit button.
Server validation will only performed when CauseValidation is set to true.
When the value of the CausesValidation property is set to true, you can also use the
ValidationGroup property to specify the name of the validation group for which the
Button control causes validation.
Page has a Validate() method. If it is true this methods is executed. Validate()
executes each validation control.
To make this happen, simply set the CauseValidation property to true for submit
button as shown below:
<asp:Button ID="Button2" runat="server" Text="Submit" CausesValidation=true />
Lets understand validation controls one by one with practical demonstration:
RequiredFieldValidation Control
The RequiredFieldValidator control is simple validation control, which checks to see
if the data is entered for the input control. You can have a RequiredFieldValidator
control for each form element on which you wish to enforce Mandatory Field rule.
1. <asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server"
2. Style="top: 98px; left: 367px; position: absolute; height
: 26px; width: 162px"
3. ErrorMessage="password required" ControlToValidate="TextB
ox2">

4. </asp:RequiredFieldValidator>

CompareValidator Control
The CompareValidator control allows you to make comparison to compare data
entered in an input control with a constant value or a value in a different control.
It can most commonly be used when you need to confirm password entered by the
user at the registration time. The data is always case sensitive.
1. <asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" Style="top: 145px;
2. left: 367px; position: absolute; height: 26px; wi
dth: 162px" ErrorMessage="password required"
3. ControlToValidate="TextBox3"></
asp:RequiredFieldValidator>
RangeValidator Control
The RangeValidator Server Control is another validator control, which checks to see
if a control value is within a valid range. The attributes that are necessary to this
control are: MaximumValue, MinimumValue, and Type.
1. <asp:RangeValidator ID="RangeValidator1" runat="server"
2. Style="top: 194px; left: 365px; position: absolute; heigh
t: 22px; width: 105px"
3. ErrorMessage="RangeValidator" ControlToValidate="TextBox4
" MaximumValue="100" MinimumValue="18" Type="Integer"></
asp:RangeValidator>
RegularExpressionValidator Control
A regular expression is a powerful pattern matching language that can be used to
identify simple and complex characters sequence that would otherwise require
writing code to perform.
Using RegularExpressionValidator server control, you can check a user's input
based on a pattern that you define using a regular expression.
It is used to validate complex expressions. These expressions can be phone
number, email address, zip code and many more. Using Regular Expression
Validator is very simple. Simply set the ValidationExpression property to any type of
expression you want and it will validate it.
CustomValidator Control
The CustomValidator Control can be used on client side and server side. JavaScript
is used to do client validation and you can use any .NET language to do server side
validation.
The server side validation you write does not need to provide the exact same
validation as that of the client side validation. The client side validation can check for
the user input data for range and type and server side validation can check for
matching of data with database. Both server side and client side validation can be
used for total solution.
ValidationSummary
[Link] has provided an additional control that complements the validator controls.
The ValidationSummary control is reporting control, which is used by the other
validation controls on a page.
You can use this validation control to consolidate errors reporting for all the
validation errors that occur on a page instead of leaving this up to each and every
individual validation control.
The validation summary control will collect all the error messages of all the non-valid
controls and put them in a tidy list.
1. <asp:ValidationSummary ID="ValidationSummary1" runat="ser
ver"
2. style="top: 390px; left: 44px; position: absolute
; height: 38px; width: 625px" />

Both ErrorMessage and Text properties are used to display error messages. Text
error message have precedence.

You might also like