【正文】
大幅度減少了生成動(dòng)態(tài)網(wǎng)頁所需的代碼量。 只需獲取現(xiàn)有 HTML 文件并將該文件的文件擴(kuò)展名更改為 .aspx,就可以創(chuàng)建一個(gè) 頁。s name and category preference and then performs a form postback to the originating page when a button is clicked: Important: Note that nothing happens yet when you click the Lookup button. This is because the .htm file contains only static HTML (no dynamic content). Thus, the same HTML is sent back to the client on each trip to the page, which results in a loss of the contents of the form fields (the text box and dropdown list) between requests. provides syntax patibility with existing ASP pages. This includes support for % % code render blocks that can be intermixed with HTML content within an .htm file. These code blocks execute in a topdown manner at page render time. The below example demonstrates how % % render blocks can be used to loop over an HTML block (increasing the font size each time): Important: Unlike with ASP, the code used within the above % % blocks is actually pilednot interpreted using a script engine. This results in improved runtime execution performance. page developers can utilize % % code blocks to dynamically modify HTML output much as they can today with ASP. For example, the following sample demonstrates how % % code blocks can be used to interpret results posted back from a client. Important: While % % code blocks provide a powerful way to custom manipulate the text output returned from an page, they do not provide a clean HTML programming model. As the sample above illustrates, developers using only % % code blocks must custom manage page state between round trips and custom interpret posted values. In addition to code and markup, pages can contain server controls, which are programmable serverside objects that typically represent a UI element in the page, such as a textbox or image. Server controls participate in the execution of the page and produce their own markup rendering to the client. The principle advantage of server controls is that they enable developers to get plex rendering and behaviors from simple buildingblock ponents, dramatically reducing the amount of code it takes to produce a dynamic Web page. Another advantage of server controls is that it is easy to customize their rendering or behavior. Server controls expose properties that can be set either declaratively (on the tag) or programmatically (in code). Server controls (and the page itself) also expose events that developers can handle to perform specific actions during the page execution or in response to a clientside action that posts the page back to the server (a postback). Server controls also simplify the problem of retaining state across roundtrips to the server, automatically retaining their values across successive postbacks. Server controls are declared within an .htm file using custom tags or intrinsic HTML tags that contain a runat=server attribute value. Intrinsic HTML tags are handled by one of the controls in the namespace. Any tag that doesn39。 提供了與現(xiàn)有 ASP 頁的語法兼容性。 服務(wù)器控件在 .aspx 文件中是使用自定義標(biāo)記或包含 runat=server 屬性值的內(nèi)部 HTML 標(biāo)記聲明的。最初,這些控件只呈現(xiàn)其 HTML 窗體等效項(xiàng)。這極大地簡化了代碼隱藏頁的維護(hù)工作。您可能需要使用頁最上方的 Import 指令從 Bin