ASP.NET is a powerful programming platform that is used to develop and
run Web based applications and services. ASP.NET provides improved features,
such as convenient debugging tools, over the earlier Web development
technologies. ASP.NET provides a rich set of controls to design Web pages.
Visual Studio .NET provides visual WYSIWYG (What You See Is What You Get) HTML
editors. Therefore, you can design Web pages by simply dragging and dropping
the controls. ASP.NET supports the C#, Visual Basic .NET, and JScript .NET
languages, all of which you can use to build programming logic for your Web
pages. You can choose which one of these languages to use based on your
proficiency on a particular language. One of the most important features of
ASP.NET is that it provides separate files for page presentation and
programming logic, which simplifies Web application development. ASP.NET
provides many useful controls that are very use into the designing Web Pages.
ASP.NET Web Forms
The ASP.NET Web Forms technology is used to create programmable Web
pages that are dynamic, fast, and interactive. Web pages created using ASP.NET
Web Forms are called ASP.NET Web Forms pages or simply Web Forms
pages. ASP.NET uses the .NET Framework and enables you to create Web pages
that are browser independent. In addition to being browser independent, the
following are some of the features that may lead you to select Web Forms over
other technologies to create dynamic Web pages:-
1. Web Forms can be designed and programmed using
Rapid Application Development (RAD) tools.
2. Web Forms support a rich set of controls and are
extensible, because they provide support for user-created and third-party
controls.
3. Any of the .NET Framework language can be used to
program the ASP.NET Web Forms pages.
4. ASP.NET uses the Common Language Runtime (CLR) of
the .NET Framework and thus benefits from its features, such as type safety and
inheritance.
Web Forms components
The functionality to respond to user interactions with the Web Forms
pages is implemented by using programming languages, such as Visual Basic .NET
and C#. You can implement the programming logic in the ASPX file or in a
separate file written in any CLR-supported language, such as Visual Basic .NET
or C#. This separate file is called the code behind file and has either
.aspx.cs or .aspx.vb as its extension depending on the language used. Thus, a
Web Forms page consists of a page - ASPX file and a code behind file - .aspx.cs
file or .aspx.vb file.
Web Forms server controls
You can design a Web Forms page by using controls called Web Forms
server controls. You can program the functionality to be provided for the
server controls. The server controls are different from the usual Windows
controls because they work within the ASP.NET Framework. The different types of
server controls are described as follows:-
HTML server controls:
These controls refer to the HTML elements that can be used in server
code. The HTML elements can be converted into HTML server controls. To do so,
you need to use attributes, such as ID and RUNAT, in the tags that are used to add the HTML controls. You can also add
these controls to the page by using the HTML tab of the toolbox.
ASP.NET server controls:
These controls do not map one-to-one to HTML server controls. ASP.NET
server controls include traditional form controls, such as text boxes and
buttons, and complex controls, such as tables.
Validation controls:
These controls are used to validate users' input. Validation controls
can be attached to input controls to check the values entered.
User controls:
These controls are created from the existing Web Forms pages and can be
used in other Web Forms pages.
Working with Events
A Web Forms application provides fast, dynamic, and user-interactive Web
Forms pages. When users interact with different Web controls on a page, events
are raised.The events are raised either on the client or on the server, but are
always handled on the server. ASP.NET server controls support only server-side
events, while HTML server controls support both server-side and client-side
events.
Round trips Events
Most Web pages require processing on the server. For example, consider
an Orders Web page used to receive orders on the Web. When a user enters a
value for the quantity of a product to be bought, the page must check on the
server to see whether or not the quantity requested is available. This type of
dynamic functionality is accomplished by handling server control events. Whenever
a user interaction requires some kind of processing on the server, the Web
Forms page is submitted to the server, processed, and then returned to the
browser (client). This sequence is called a round trip.
Event handlers
When the events are raised, you need to handle them for processing. The
procedures that are executed when an event occurs are called event handlers.
An event handler is associated with the corresponding event by using the With Events and Handles keywords. The With Events keyword is used to
declare the control generating an event. For example, when you declare a
control, say Image1 as 'Protected with Events Image1 as System.Web.UI.WebControls.Image',
the With Events keyword specifies that Image1 is an object variable used to respond to events raised by the instance assigned
to the variable. The Handles keyword is used to associate the event handler with the event, which is
raised by the control. The control in turn is declared by using the With Events keywords.
Handling post back
As mentioned earlier, the Web Forms page is posted back to the server
only when a Button, LinkButton, or ImageButton ASP.NET server control is clicked. After the page is
posted to the server, it is processed there. You can respond to a button event
in one of the following ways:-
1. Write an event handler for the Click event of the button
2. Write the event handler for the Load event of the
Web Forms page. The Load event is generated when the form is loaded from the
server to the client (browser). You can use the IsPostBack property in the Load
event to determine whether the page has been processed for the first time or by
a button click.
Using the view state
In all Web applications, whenever a Web page is processed at the server,
the page is created from scratch. In traditional Web applications, the server
discards the page information after processing and sending the page to the
browser. Because the page information is not preserved on the server, the Web
pages are called stateless. However, the Web Forms framework works around this
limitation and can save the state information of the form and its controls. To
implement this, the Web Forms framework provides the following options:-
1. The ViewState: The framework
automatically saves the state of the page and its current properties, and the
state of the server controls and their base properties, with each round trip.
2. The State Bags: Every page has a
state bag that stores values to be restored in the next round trip.
The framework automatically stores and restores page information with
each round trip. So, you do not need to worry about storing and restoring the
page information with each round trip. The ViewState contains the state of all
the controls on a page between requests sent to the server. The state
information is stored as hidden form fields as name-value pairs in the System.Web.UI.StateBag object. When you
view an ASP.NET page in a browser, you can see the ViewState for this page by displaying the source code of the page.
https://www.youtube.com/channel/UCKLRUr6U5OFeu7FLOpQ-FSw/videos
https://www.youtube.com/channel/UCKLRUr6U5OFeu7FLOpQ-FSw/videos
0 comments
Post a Comment