asp.net asp.net as an integral part of Visual Studio.NET, developed from ASP, but not a simple upgrade of ASP, but a new generation of Active Server Pages from Microsoft.
ASP.net is an important part of Microsoft's. NET Framework, which uses vb.net, C #, and JScript.NET programming languages to implement Dynamic Web programming, making its programming very flexible and efficient. At the same time ASP.net is based on component technology and object-oriented development system, programmers can use the rich components of the system, such as file upload, e-mail delivery, file operations, advertising components. Not only that, programmers can also develop their own components to extend the functionality of ASP.net.
asp.net directly supports component and Code-behind technology, it can better implement the separation of program code and HTML code. ASP.net adopts a new database access technology called Ado.net, which can greatly improve the efficiency of data access, and also can easily develop database application system.
The operation and development environment of ASP.net
1.asp.net's operating environment
(1) Hardware requirements
Cpu:intel Pentium II (best Intel Pentium III MHz)
Memory: MB (preferably 128 MB)
Disk Space: MB (fully installed) MB (Quick Install)
Display: 800x600, 256 colors
CD-ROM: Speed optical drive
(2) Software requirements
Windows Professional, Windows Server, Windows Advanced Server, IE 5.5, ngws.
ASP.net currently supports C #, VB, Jscrip and other three languages.
Second, the installation of ASP.net
1. Install asp.net
You can download the ASP.net installer from here: Http://download.microsoft.com/download/platformsdk/trial/1812.10full/nt5/en-us/setup.exe. The asp.net installation process is simple and can be done simply by following a simple installation. However, if you have Office 2000 installed on your computer, it is recommended that you back up the asp.net before installing the \microsoft Office\office\mso9.dll file because office prompts you to sign up after ASP.net is installed, otherwise Office 2000 will have a 50-time limit. At this point, the backup Mso9.dll file is overwritten with the original file.
2.ngws
ASP.net is actually part of a new running structure that provides support for all Windows applications. This structure is a key part of Microsoft's next Generation Web Services (NGWS). When you install the structure, you also get the asp.net. This structure also supports all other server program technologies.
The NGWS architecture extends COM's structure by adding (new and enhanced services) to upgradeable distributed applications, which are often used to write reusable software components that can be reused, and these new and enhanced services are:
A unified and rich library of programs, a multilingual running engine, simple application setup, debugging, and maintenance, enhanced scalability for distributed applications, and protection of existing software and investments.
Three, ASP.net concept analysis
1.web form
The form, the English word is form. In the. NET architecture, form is a frequently used word. The Web form represents a single Web page. In general, a form is like a container for a variety of controls, which must be directly or indirectly dependent on it. The word "form", in the eyes of web programmers, is always confused with the "form" inside HTML. Web Forms seem more appropriate to translate to Web pages.
We still remember that the form in VB is actually an object, it can have its own properties, methods, events and so on. Web Forms, or a Web page is actually an object. The more important concept in the. NET architecture is "objects", all controls are objects, and even data types are objects; Each data type has its own unique properties and methods. We will experience it in later programming.
The suffix name for the Web form is aspx. When a browser requests an ASPX file for the first time, the Web Form page is compiled by the CLR (Common language Runtime) compiler. Since then, when another user accesses this page, the CLR will execute the compiled code directly because the ASPX page has been compiled, which is completely different from the ASP. ASP only supports explanatory scripting languages such as VBScript and JavaScript. So the ASP page is interpreted for execution. When the user makes a request, whether it is the first time, or the 1000th time, the ASP's pages will be dynamically interpreted and executed. ASP.net supports a compiled language, including vb.net, C #, JScript.NET, and so on. So, ASP.net is a compilation that executes more than once.
To simplify the programmer's work, the ASPX page does not need to be compiled manually, but rather the CLR decides whether to compile it when the page is invoked. In general, in the following two cases, ASPX is recompiled:
(1) The first time the ASPX page is requested by the browser;
(2) ASPX is rewritten.
Because ASPX pages can be compiled, ASPX pages have the same performance as components. This allows the ASPX page to be at least 250% faster than the same functional ASP page!
Network forms bring the advantage of the high efficiency of the VB form to the development of the network application. Network forms Support Traditional ASP syntax that mixes HTML content with scripting code, but it proposes a more structured approach to separating application code from user interface content. The introduced network form controls are used to provide a mechanism for encapsulating common user interface elements. These new features enable the development tool to support the design-time module while supporting the VB application, enabling WYSIWYG (WYSIWYG) tools to support the layout of the Web page.
The Network form control is responsible for building the user interface, typically in an HTML form. ASP.net provides a set of network form controls that map traditional HTML user interface widgets (including list boxes, text boxes, and buttons) and a set of more complex network controls (such as calendars and billboards). An important feature of these controls is that they can be written to fit the client's capabilities; the same Web page targets a wide range of client platforms and form factors. In other words, a network form control can "probe" to a customer who is looking for a form, and then return the appropriate HTML 3.2, or Dynamic HTML for IE 5.0, that might be appropriate for a low-level browser.
Considering that the network is a stateless join model, a complex problem faced by network application developers is that they respond to user interactions with web-based interfaces. The network leverages the ASP.net architecture to provide a rich set of services to help developers build interactive Web pages. The role of these services is to make component-based, event-driven programmable modules that are very much like client-side form programming for developers. The complexity of the state management of user interaction with Web pages is hidden by asp.net network forms and network form controls. For developers, the rich data-binding services provided make it easy to display data from data access services.
The separation of code and content enables ASP.net Web pages to be dynamically compiled into controlled classes to improve performance. Each incoming HTTP request is passed to a new Web page instance, so the developer does not need to care about thread security in the code.
2.namespace (name space)
Objects have been the center of program Development in the Windows Development environment. Whether in VB, VBA, VC + +, VBScript and so on, the different development environment has different objects, these objects are the various grammar provided "resources", program developers can use these resources to write the required system.
In the past ASP, only the server, request, response ... And so on seven objects. In ASP.net, the object library is finely divided.
For example, in a asp.net web page to get data from a database through an SQL statement, you must use "System.data.sql", which is the namespace (name space) name. Under the System.data.sql, there are also many classes (class). Each class can be treated as an object because there are properties, methods, and events under the class
Therefore, the topmost namespace is considered a collection of objects of the same type, and a namespace can have more than one class. The relationship between them is as follows (Fig)
3. File type
ASP has only one file type, and its extension is. asp files. But there are a lot of file types in asp.net:
Figure
Four, the ASP.net control application
asp.net provides four types of controls, server-side controls, validation controls, HTML controls, and custom controls that take advantage of the functionality provided by these controls to speed up the task.
1. Server-side controls
In ASP.net, everything is an object, and the Web page itself is an object. Or, a Web page is a container for an object. Server-side controls, English is the server control, is placed in this container.
What is control? Simply put, control is a reusable component or object that not only has its own appearance but also its own data and methods, and most components can respond to events. With Microsoft's integrated development Environment (Visual Studio.NET), you can simply drag and drop a control into a form.
Why is it called "server control"? This is because the control is present on the server side. Server-side controls also have their own appearance, and in the client browser, the appearance of server control is represented by HTML code. Server control automatically generates browser-appropriate HTML code when initialized, according to the client's browser version. The main server-side controls and their uses are shown in the following table:
Figure
Example 1: Server control
Id= "Txtlogin"
text= "Text Editing"
font_face= "Arial" font_size= "3"
Backcolor= "LightBlue"
Textmode= "Multiline"
heigth=10
Ontextchanged= "txtlogin_changed ()"
/>
text= "checkbox 1"
Autopostback= "true"
/>
repeatlayout= "Flow"
>
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
2. Validation controls
This is a very important way to verify that user input information in a Web page is valid. A set of validation controls are provided in the ASP.net Web from framework, which provides a powerful and easy-to-use way to check for errors and to display prompts to the user if needed. These controls can be divided into several types as described in the following table: (Fig)
Example 2: Validating controls
Controltovalidate= "Txtlastname"
Errormessage= "Last name is a required field"
Forecolor= "Red" >
Forecolor= "Red"
Controltovalidate= "Txtdeparturedate"
Controltocompare= "Txtarrivaldate"
Type= "datetime"
Operator= "Greaterthanequal"
Errormessage= "Departure date cannot be earlier than arrival date." >
Forecolor= "Red"
Controltovalidate= "Txtage"
Valuetocompare=0
Type= "Integer"
Operator= "Greaterthanequal"
Errormessage= "Please enter a whole number zero or greater." >
Controltovalidate= "Text1"
Errormessage= "You must enter at least 8 characters!"
Clientvalidationfunction= "Validatelength (o, v)" >
Zip:
Id=txtzip_validation runat= "Server"
Controltovalidate= "Txtzip"
Errormessage= "Enter a valid US zip code."
Validationexpression= "[0-9]{6,6}" >
3. HTML server Control
HTML controls are visible on the server side, so we can write them according to our wishes. HTML controls behave as visible controls.
HTML server controls correspond directly to HTML elements, and each HTML server control supports properties and methods of common controls that can be bound to a data source.
Figure
Example 3:html Control Sample:
customizing page controls
Of course, we can also generate more complex custom controls, here is not much to say, interested in please refer to the ASP.net help file with C #, vb.net, etc. to write powerful controls, in general, these controls can be compiled into a. dll file for use at any time.
V. Database operations
The operation of the database is done mainly through the ado.net and dataset in asp.net. Ado.net and ADO in ASP, it is an improved version of ADO. A dataset is the central concept of ado.net. You can imagine a dataset as a database in memory. It is precisely because of the dataset that programmers can screen the differences between databases in order to obtain a consistent programming model. The dataset supports multiple tables, relationships between tables, data constraints, and so on. These and relational database models are basically the same. In the past, data processing depended primarily on a two-tier structure and was based on connectivity. The connection is disconnected and the data is no longer accessible. Now, data processing is extended to more than three layers of structure, and, accordingly, programmers need to switch to a connectionless application model. In this way, DataSetCommand plays a very important role in ado.net. It can retrieve a dataset and maintain a "bridge" between a data source and a dataset for data access, modification, and preservation. DataSetCommand automatically transforms the various operations of the data into appropriate SQL statements related to the data source.
The steps to access a database are: ado.net
(1) Create a database link;
(2) Request a collection of records;
(3) Staging the collection of records to a dataset;
(4) If necessary, return to step 2nd; (DataSet can hold multiple data sets)
(5) Close the database link;
(6) Doing the required operation on the dataset.
The dataset internally uses XML to describe the data. Because XML is a platform-independent, language-independent data Description language, and can describe data for complex data relationships, such as parent-child relationships, datasets can actually accommodate data with complex relationships and no longer rely on database links.
We use a very short example to illustrate the database connection, retrieval, more operations such as additions, deletions, modifications, etc. please refer to the asp.net documentation.
Example: Database connection, retrieval
ASP.net has a lot of features, and here's just some of its basic features, advanced features such as Web applications, Web service, performance optimization, XML integration, three-tier architecture, and Message Queuing MSMQ require you to refer to the appropriate professional books for overall understanding and mastery.