Professional Documents
Culture Documents
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 offers several important advantages
over previous Web development models.
Enhanced Performance
ASP.NET is a compiled common language runtime code running on the server. Unlike its
interpreted predecessors, ASP.NET can take advantage of early binding, just-in-time compilation,
native optimization, and caching services right out of the box. This amounts to dramatically better
performance before you ever write a line of code.
The ASP.NET framework is complemented by a rich toolbox and designed in the Visual Studio
integrated development environment. WYSIWYG editing, drag-and-drop server controls, and
automatic deployment are just a few of the features this powerful tool provides.
As ASP.NET is based on the common language runtime, the power and flexibility of that entire
platform is available to Web application developers. The .NET Framework class library,
Messaging, and Data Access solutions are all seamlessly accessible from the Web. ASP.NET is
also language-independent, so you can choose the language that best applies to your application
or partition your application across many languages. Further, common language runtime
interoperability guarantees that your existing investment in COM-based development is preserved
when migrating to ASP.NET.
Simplicity
ASP.NET makes it easy to perform common tasks, from simple form submission and client
authentication to deployment and site configuration. For example, the ASP.NET page framework
allows you to build user-interfaces that cleanly separate application logic from presentation code
and to handle events in a simple, Visual Basic-like forms processing model. Additionally, the
common language runtime simplifies development, with managed code services such as
automatic reference counting and garbage collection.
Manageability
ASP.NET employs a text-based, hierarchical configuration system, which simplifies the applying
of settings to your server environment and Web applications. As configuration information is
stored as plain text, new settings may be applied without the aid of local administration tools. This
"zero local administration" philosophy extends to deploying ASP.NET Framework applications as
well. An ASP.NET Framework application is deployed to a server simply by copying the
necessary files to the server. No server restart is required, even to deploy or replace running
compiled code.
ASP.NET has been designed with scalability in mind, with features specifically tailored to improve
performance in clustered and multiprocessor environments. Further, processes are closely
monitored and managed by the ASP.NET runtime, so that if one misbehaves (leaks, deadlocks),
a new process can be created in its place, which helps keep your application constantly available
to handle requests.
ASP.NET delivers a well-factored architecture that allows developers to "plug-in" their code at the
appropriate level. In fact, it is possible to extend or replace any subcomponent of the ASP.NET
runtime with your own custom-written component. Implementing custom authentication or state
services has never been easier.
Security
With built in Windows authentication and per-application configuration, you can be assured that
your applications are secure
.aspx extension
Web Forms are commonly referred to as ASP.NET pages or ASPX pages. Web Forms have
an .aspx extension and work as the containers for the text and controls that you want to display
on the browser.
ASP.NET (.aspx) pages and Active Server Pages (ASP) (.asp) can coexist on the same server.
The file extension determines whether ASP or ASP.NET processes it.
Web Forms are often comprised of two separate files: the .aspx file which contains the UI for the
Web Form, while the .aspx.vb or .aspx.cs file, which is called a code-behind page, that contains
the supporting code.
Page attributes
The functions of a Web Form are defined by three levels of attributes. Page attributes define
global functions, body attributes define how a page will be displayed, and form attributes define
how groups of controls will be processed. The <@Page> tag defines page-specific attributes that
are used by the ASP.NET page parser and compiler. You can include only one <@ Page> tag
per .aspx file. The following examples are typical <@ Page> tags for Microsoft Visual Basic®
.NET and for Microsoft Visual C#T .NET:
[VB.NET]
<%@ Page Language="vb" Codebehind="WebForm1.aspx.vb" SmartNavigation="true" %>
[C#]
<%@ Page Language="c#" Codebehind="WebForm1.aspx.cs" SmartNavigation="true" %>
3. Creating a Web Form in Visual Studio .NET
Introduction
Depending on where you are in your development cycle, there are several ways that you can
create a Web Form.
To create a new ASP.NET Web Application project and a default Web Form:
1. In Visual Studio .NET, on the Start Page, click New Project.
2. In the New Project dialog box, click ASP.NET Web Application, type the project name in
the Location field, and then click OK.
3. Visual Studio .NET creates a new Web application and a default Web Form that is named
WebForm1.aspx.
Introduction
ASP.NET server controls are components that run on the server and encapsulate UI and other
related functionalities. Server controls are used in ASP.NET pages and in ASP.NET code-behind
classes. Server controls include buttons, text boxes, and drop-down lists. The following is an
example of a Button server control:
<asp:Button id="Button1" runat="server" Text="Submit" />
Runat="Server"
Server controls have a runat="server" attribute, the same attribute as Web Forms. This means
that the logic in the control runs on the server and not on the user's browser. Server controls are
different from HTML controls in a way that they run only on the client's browser and have no
action on the server. Another feature of server controls is that the view state, the settings, and the
user input of the control are automatically saved when the page is sent back and forth between
the client and the server. Traditional HTML controls are stateless and revert to their default
setting when the page is returned from the server to the client.
Built-in functionality
The functionality of a control is what happens when the user clicks a button or a list box. These
processes are called event procedures. As the Web Form programmer, you determine the event
procedures that are associated with each server control.
When this page is accessed by a user with Internet Explorer 6, the common language runtime
creates the following HTML customized for Internet Explorer 6:
The objective of this exercise is to introduce how to create a Microsoft® ASP.NET Web Form,
populate it with Web controls and set properties of Web controls on an ASP.NET Web Form.
Important
Only perform this procedure if you have not created a ASPNetLabApplicationVB solution file.
• Using Visual Studio .NET, create a new blank solution named ASPNetLabApplicationVB:
1. On the File menu, point to New, and then click Blank Solution.
2. In the New Project dialog box, type ASPNetLabApplicationVB in the Name text box, and then
click OK..
• Create a new ASP.NET Web Application project, named ASPNetHOL01VB for your preferred
language, in the ASPNetLabApplicationVB solution:
1. On the File menu, point to New, and then click Project.
2. In the New Project dialog box, on the Project Types list, click Visual Basic Projects.
3. In the Templates list, click ASP.NET Web Application.
4. Set the Location to http://localhost/ASPNetHOL01VB for a Visual Basic .NET project, click Add to
Solution, and then click OK.
• You will create a new Web Form named Default.aspx. You will then add a TextBox, Button,
Label and Calendar control to the Default.aspx page. Finally, you will set the format of the
calendar control by using properties window.
1. In Solution Explorer, right-click the project node, choose Add and then Add New Item.
2. Under Categories, choose UI.
3. Under Templates, select Web Form.
4. Type Default.aspx for the Name:
5. Click Open
1. In the Property Pages dialog box, select FlowLayout (instead of GridLayout) in the Page
Layout field, and then click OK. The grid disappears.
2. Add a Button control to the Web form, and view the page in HTML view. The new button does not
have a style attribute.
1. In Design view, add a Calendar Web server control onto the Web Form, and then view the page in
HTML view. Locate the HTML for the Calendar control:
<asp:Calendar id="Calendar1" runat="server"></asp:calendar>
2. Save your changes and view the page in the browser, and then view the source of the page.
Notice the entire HTML that is generated by the Calendar control.
3. Close the source view of the page.
4. Edit the page and point out the properties of the Calendar control in the Properties window
5. Right-click the Calendar control on the Web Form in Design view and select Auto Format to
show the different styles in the Calendar Auto Format dialog box. Click Colorful1, and then click
OK.
6. Save your changes and view the page in the browser again to see the new appearance of the
Calendar control.