WT Unit6 ASP Net
WT Unit6 ASP Net
NET)
ASP.NET
It is a web framework designed and developed by Microsoft. It is used to develop websites, web applications
and web services. It provides fantastic integration of HTML, CSS and JavaScript. It was first released in January
2002. It is built on the Common Language Runtime (CLR) and allows programmers to write code using any
supported .NET language.
ASP.NET is a web framework designed by Microsoft Inc. that is extensively used to build robust web
applications.
Following are some main advantages of ASP.NET which makes it better than other frameworks
available in the market:
The ASP.NET framework is facilitated by a powerful toolkit and designer in the integrated
development environment of Visual Studio. Drag-and-drop server controls and auto-deployment are
only a couple of the features this versatile tool offers.
ASP.NET framework reduces higher costs along with creating custom web applications with all
features.
The most recent framework of ASP.NET is ASP.NET core which is an open-source, cross-platform,
and cloud-based internet-connected web application.
ASP.NET core encourages the creation of effective web apps along with mobile apps and IoT apps.
These applications offer improved efficiency by taking advantage of early linking, just-in-time
compilation, native optimization, and caching services straight out of the box.
ASP.NET greatly decreases the amount of code needed to build massive applications with tighter
security and improved performance.
Lesser code encourages the application to easily manage and effectively maintain.
These applications have windows authentication which makes the applications more secure.
In ASP.NET applications, source code and HTML files are together, so ASP.NET pages are easy to
manage and write. The source code is now being run on the computer. This gives the websites a lot
of strength and versatility.
ASP.NET is strictly server-side programming, so the ASP.NET code will run on the server before it is
sent to the browser.
These applications are language-independent, so it allows you to select the language that is best for
you.
All processes are tightly supervised and handled by the ASP.NET runtime, meaning that if the
process is dead, a new process can be generated in place, which helps keep the applications
continuously ready to handle requests.
ASP.NET helps in developing robust web application.
1
into a CPU independent intermediate language (IL) code. A Just In Time(JIT) compiler compiles the IL code
into native code, which is CPU specific.
(8) ADO.NET
It is the technology used for working with data and databases. It provides access to data sources like SQL
server, OLE DB, XML etc. The ADO.NET allows connection to data sources for retrieving, manipulating, and
updating data.
2
It provides a separation between the user interface and the business logic. It helps in developing visually
stunning interfaces using documents, media, two and three dimensional graphics, animations, and more.
(13) LINQ
It imparts data querying capabilities to .Net languages using a syntax which is similar to the tradition query
language SQL.
In ASP.NET, a web page has execution lifecycle that includes various phases. These phases include
initialization, instantiation, restoring and maintaining state etc. it is required to understand the page lifecycle
so that we can put custom code at any stage to perform our business logic.
The following table contains the lifecycle stages of ASP.NET web page.
Stage Description
Page request This stage occurs before the lifecycle begins. When a page is requested by the user, ASP.NET
parses and compiles that page.
3
Start In this stage, page properties such as Request and response are set. It also determines the Request
type.
Initialization In this stage, each control's UniqueID property is set. Master page is applied to the page.
Load During this phase, if page request is postback, control properties are loaded with information.
Postback In this stage, event handler is called if page request is postback. After that, the Validate method
event handling of all validator controls is called.
Rendering Before rendering, view state is saved for the page and all controls. During the rendering stage, the
page calls the Render method for each control, providing a text writer that writes its output to the
OutputStream object of the page's Response property.
Unload At this stage the requested page has been fully rendered and is ready to terminate.at this stage
all properties are unloaded and cleanup is performed.
Web Pages is one of many programming models for creating ASP.NET web sites and web applications.
Web Pages provides an easy way to combine HTML, CSS, and server code:
In addition, Web Pages applications are easily extendable with programmable helpers for databases, videos,
graphics, social networking and more.
An event is an action or occurrence such as a mouse click, a key press, mouse movements, or any system-
generated notification. A process communicates through events. For example, interrupts are system-
generated events. When events occur, the application should be able to respond to it and manage it.
Events in ASP.NET raised at the client machine, and handled at the server machine. For example, a user clicks
a button displayed in the browser. A Click event is raised. The browser handles this client-side event by
posting it to the server.
The server has a subroutine describing what to do when the event is raised; it is called the event-handler.
Therefore, when the event message is transmitted to the server, it checks whether the Click event has an
associated event handler. If it has, the event handler is executed..
Page and Control Events
Common page and control events are:
4
DataBinding - It is raised when a control binds to a data source.
Disposed - It is raised when the page or the control is released.
Error - It is a page event, occurs when an unhandled exception is thrown.
Init - It is raised when the page or the control is initialized.
Load - It is raised when the page or a control is loaded.
PreRender - It is raised when the page or the control is to be rendered.
Unload - It is raised when the page or control is unloaded from memory.
Event Handling Using Controls
All ASP.NET controls are implemented as classes, and they have events which are fired when a user performs
a certain action on them. For example, when a user clicks a button the 'Click' event is generated. For handling
events, there are in-built attributes and event handlers. Event handler is coded to respond to an event, and
take appropriate action on it.
By default, Visual Studio creates an event handler by including a Handles clause on the Sub procedure. This
clause names the control and event that the procedure handles.
The ASP tag for a button control:
Handles btnCancel.Click
End Sub
An event can also be coded without Handles clause. Then, the handler must be named according to the
appropriate event attribute of the control.
The ASP tag for a button control:
End Sub
5
ASP.NET Server Object and Control:
ASP.NET server controls are the primary controls used in ASP.NET. These controls can be grouped into the
following categories:
Validation controls - These are used to validate user input and they work by running client-
side script.
Data source controls - These controls provides data binding to different data sources.
Data view controls - These are various lists and tables, which can bind to data from data
sources for displaying.
Personalization controls - These are used for personalization of a page according to the user
preferences, based on user information.
Login and security controls - These controls provide user authentication.
Master pages - These controls provide consistent layout and interface throughout the
application.
Navigation controls - These controls help in navigation. For example, menus, tree view etc.
Rich controls - These controls implement special features. For example, AdRotator,
FileUpload, and Calendar control.
The syntax for using server controls is:
Property Description
AccessKey Pressing this key with the Alt key moves focus to the control.
Attributes It is the collection of arbitrary attributes (for rendering only) that do not correspond to
properties on the control.
6
BorderStyle Border style.
7
ASP.NET Web Service:
A web service is a web-based functionality accessed using the protocols of the web to be used by the web
applications. There are three aspects of web service development:
Creation:
1. Create a new website by selecting "ASP.NET Web Site" and giving it a suitable name.
2. service.cs file appears inside the solution with a default webmethod named as "HelloWorld()".
3. Right click on the webservice project and add a web reference instead of adding a normal
reference.
4. A window appears that displays a list of webservices knows to the solution.
5. Click on "Webservices in this solution"
6. a search progress bar appears and
7. Select the service that appears in the list
8. Progress bar appears once again.
9. Web method appears on the screen
10. Click on "Add reference" button. This would add localhost
11. Solution would have App_WebReference folder
Consumption or Usage: