1、外文文献原文 What is ASP.NET? 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 compiled common language
2、 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. World
3、-Class Tool Support. The ASP.NET framework is complemented by a rich toolbox and designer 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. Power and Flexibilit
4、y. Because 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-indepe
5、ndent, 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
6、.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
7、 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 simplif
8、ies applying settings to your server environment and Web applications. Because 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 a
9、s 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. Scalability and Availability. ASP.NET has been designed with scalability in mind, with features specif
10、ically 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 avai
11、lable to handle requests. Customizability and Extensibility. 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 componen
12、t. 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. Data Binding Overview and Syntax ASP.NET introduces a new declarative data binding sy
13、ntax. This extremely flexible syntax permits the developer to bind not only to data sources, but also to simple properties, collections, expressions, and even results returned from method calls. The following table shows some examples of the new syntax. Although this syntax looks similar to the ASP
14、shortcut for Response.Write - - its behavior is quite different. Whereas the ASP Response.Write shortcut syntax was evaluated when the page was processed, the ASP.NET data binding syntax is evaluated only when the DataBind method is invoked. DataBind is a method of the Page and all server controls.
15、When you call DataBind on a parent control, it cascades to all of the children of the control. So, for example, DataList1.DataBind() invokes the DataBind method on each of the controls in the DataList templates. Calling DataBind on the Page - Page.DataBind() or simply DataBind() - causes all data bi
16、nding expressions on the page to be evaluated. DataBind is commonly called from the Page_Load event, as shown in the following example. You can use a binding expression almost anywhere in the declarative section of an .aspx page, provided it evaluates to the expected data type at run time. The simpl
17、e property, expression, and method examples above display text to the user when evaluated. In these cases, the data binding expression must evaluate to a value of type String. In the collection example, the data binding expression evaluates to a value of valid type for the DataSource property of Lis
18、tBox. You might find it necessary to coerce the type of value in your binding expression to produce the desired result. For example, if count is an integer: Number of Records: Binding to Simple Properties The ASP.NET data binding syntax supports binding to public variables, properties of the Page, a
19、nd properties of other controls on the page. The following example illustrates binding to a public variable and simple property on the page. Note that these values are initialized before DataBind() is called. The following example illustrates binding to a property of another control. Binding to Coll
20、ections and Lists List server controls like DataGrid, ListBox and HTMLSelect use a collection as a data source. The following examples illustrate binding to usual common language runtime collection types. These controls can bind only to collections that support the IEnumerable, ICollection, or IList
21、Source interface. Most commonly, youll bind to ArrayList, Hashtable, DataView and DataReader. The following example illustrates binding to an ArrayList. The following example illustrates binding to a DataView. Note that the DataView class is defined in the System.Data namespace. The following exampl
22、e illustrates binding to a Hashtable. Binding Expressions or Methods Often, youll want to manipulate data before binding to your page or a control. The following example illustrates binding to an expression and the return value of a method. DataBinder.Eval The ASP.NET framework supplies a static met
23、hod that evaluates late-bound data binding expressions and optionally formats the result as a string. DataBinder.Eval is convenient in that it eliminates much of the explicit casting the developer must do to coerce values to the desired data type. It is particularly useful when data binding controls
24、 within a templated list, because often both the data row and the data field must be cast. Consider the following example, where an integer will be displayed as a currency string. With the standard ASP.NET data binding syntax, you must first cast the type of the data row in order to retrieve the dat
25、a field, IntegerValue. Next, this is passed as an argument to the String.Format method. This syntax can be complex and difficult to remember. In contrast, DataBinder.Eval is simply a method with three arguments: the naming container for the data item, the data field name, and a format string. In a t
26、emplated list like DataList, DataGrid, or Repeater, the naming container is always Container.DataItem. Page is another naming container that can be used with DataBinder.Eval. The format string argument is optional. If it is omitted, DataBinder.Eval returns a value of type object, as shown in the fol
27、lowing example. It is important to note that DataBinder.Eval can carry a noticeable performance penalty over the standard data binding syntax because it uses late-bound reflection. Use DataBinder.Eval judiciously, especially when string formatting is not required. Section Summary The ASP.NET declara
28、tive data binding syntax uses the notation. You can bind to data sources, properties of the page or another control, collections, expressions, and results returned from method calls. List controls can bind to collections that support the ICollection, IEnumerable, or IListSource interface, such as Ar
29、rayList, Hashtable, DataView, and DataReader. DataBinder.Eval is a static method for late binding. Its syntax can be simpler than the standard data binding syntax, but performance is slower. Section Summary The DataList and Repeater controls provide developers fine-tuned control over the rendering of data-bound lists. Rendering of bound data is controlled using a template, such as the HeaderTemplate, FooterTemplate, or ItemTemplate. The Repeater control is a general-purpose iterator, and does not insert anything