【正文】
s, you need to understand that pages are piled before they are executed. This means that pages can execute very quickly. The first time you request an page, the page is piled into a .NET class, and the resulting class file is saved beneath a special directory on your server named Temporary Files. For each and every page, a corresponding class file appears in the Temporary Files directory. Whenever you request the same page in the future, the corresponding class file is executed. When an page is piled, it is not piled directly into machine code. Instead, it is piled into an intermediatelevel language called Microsoft Intermediate Language (MSIL). All .NETpatible languages are piled into this intermediate language. An page isn39。 Technique 1. Building Pages and the .NET Framework is part of Microsoft39。s overall .NET framework, which contains a vast set of programming classes designed to satisfy any conceivable programming need. In the following two sections, you learn how fits within the .NET framework, and you learn about the languages you can use in your pages. The .NET Framework Class Library Imagine that you are Microsoft. Imagine that you have to support multiple programming languages— such as Visual Basic, JScript, and C++. A great deal of the functionality of these programming languages overlaps. For example, for each language, you would have to include methods for accessing the file system, working with databases, and manipulating strings. Furthermore, these languages contain similar programming constructs. Every language, for example, can represent loops and conditionals. Even though the syntax of a conditional written in Visual Basic differs from the syntax of a conditional written in C++, the programming function is the same. Finally, most programming languages have similar variable data types. In most languages, you have some means of representing strings and integers, for example. The maximum and minimum size of an integer might depend on the language, but the basic data type is the same. Maintaining all this functionality for multiple languages requires a lot of work. Why keep reinventing the wheel? Wouldn39。t piled into native machine code until it is actually requested by a browser. At that point, the class file contained in the Temporary Files directory is piled with the .NET framework Just in Time (JIT) piler and executed. The magical aspect of this whole process is that it happens automatically in the background. All you have to do is create a text file with the source code for your page, and the .NET framework handles all the hard work of converting it into piled code for you. ASP CLASSIC NOTE What about VBScript? Before , VBScript was the most popular language for developing Active Server Pages. does not support VBScript, and this is good news. Visual Basic is a superset of VBScript, which means that Visual Basic has all the functionality of VBScript and more. So, you have a richer set of functions and statements with Visual Basic. Furthermore, unlike VBScript, Visual Basic is a piled language. This means that if you use Visual Basic to rewrite the same code that you wrote with VBScript, you can get better performance. If you have worked only with VBScript and not Visual Basic in the past, don39。ll find it easy to make the transition between the two languages. NOTE Microsoft includes an interesting tool named the IL Disassembler (ILDASM) with the .NET framework. You can use this tool to view the disassembled code for any of the classes in the Temporary Files directory. It lists all the methods and properties of the class and enables you to view the intermediatelevel code. This tool also works with all the controls discussed in this chapter. For example, you can use the IL Disassembler to view the intermediatelevel code for the TextBox control (located in a file named ). Introducing Controls controls provide the dynamic and interactive portions of the user interface for your Web application. The controls render the content that the users of your Web site actually see and interact with. For example, you can use controls to create HTML form elements, interactive calendars, and rotating banner advertisements. controls coexist peacefully with HTML content. Typically, you create the static areas of your Web pages with normal HTML content and create the dynamic or interactive portions with controls. The best way to understand how controls work in an HTML page is to look at a simple Web Forms Page. Adding Application Logic to an Page The second building block of an page is the application logic, which is the actual programming code in the page. You add application logic to a page to handle both control and page events. If a user clicks a Button control within an HTML form, for example, the Button control raises an event (the Click event). Typically, you want to add