ASP.NET 2.0 Cookbook, 2/e
暫譯: ASP.NET 2.0 食譜, 第2版

Michael A Kittel, Geoffrey T. LeBlond

  • 出版商: O'Reilly
  • 出版日期: 2005-12-01
  • 售價: $2,070
  • 貴賓價: 9.5$1,967
  • 語言: 英文
  • 頁數: 1024
  • 裝訂: Paperback
  • ISBN: 0596100647
  • ISBN-13: 9780596100643
  • 相關分類: .NETASP.NET
  • 已過版

買這商品的人也買了...

相關主題

商品描述

Description

Completely revised for ASP.NET 2.0, this new edition of the best-selling ASP.NET Cookbook has everything you need to go from beginning to advanced Windows-based web site development using Microsoft's popular Visual Studio 2005 and ASP.NET 2.0 developer tools. Written for the impatient professional, ASP.NET 2.0 Cookbook contains more than 125 recipes for solving common and not-so-common problems you are likely to encounter when building ASP.NET-based web applications.


The recipes in this book, which run the gamut from simple coding techniques to more comprehensive development strategies, are presented in the popular Problem-Solution-Discussion format of the O'Reilly Cookbook series. As with the first edition, every solution is coded in both C# and Visual Basic 2005.


Among the additions and revisions to this new edition are:

  • Three new chapters, including 25 new recipes for Master and Content pages, Personalization using Profiles and Themes, Custom Web Parts, and more
  • New code for every solution, rewritten to take advantage of features and techniques new to ASP.NET 2.0 and available for download


The ASP.NET 2.0 Cookbook continues to provide the most comprehensive coverage you'll find anywhere of:

  • Tabular controls, including the new GridView control
  • Data validation, including the new ASP.NET 2.0 validation controls, as well as techniques for performing your own validation programmatically
  • User and custom controls
  • Error handling, performance tuning, and caching

Table of Contents

Preface

1. Master Pages

      1.1 Generating a Quick Master/Content Page Arrangement  

      1.2 Extending a Master Page's Content to Include Content for Other Application Pages  

      1.3 Changing Which Master Page Is Used Without Modifying All Affected Application Pages  

      1.4 Setting the Master Page at Runtime  

2. Tabular Data

      2.1 Selecting the Right Tabular Control  

      2.2 Generating a Quick-and-Dirty Tabular Display  

      2.3 Enhancing the Output of a Tabular Display  

      2.4 Displaying Data from an XML File  

      2.5 Displaying an Array as a Group of Checkboxes  

      2.6 Displaying Data from a Hashtable  

      2.7 Adding Next/Previous Navigation to a DataGrid  

      2.8 Adding First/Last Navigation to a DataGrid  

      2.9 Adding Direct Page Navigation to a DataGrid  

      2.10 Sorting Data in Ascending/Descending Order Within a DataGrid  

      2.11 Combining Sorting and Paging in a DataGrid  

      2.12 Paging Through a Record-Heavy DataGrid  

      2.13 Editing Data Within a DataGrid  

      2.14 Navigating and Sorting Within a GridView  

      2.15 Updating a GridView Without Refreshing the Whole Page  

      2.16 Editing Data in a GridView  

      2.17 Inserting a Row Within a GridView  

      2.18 Formatting Columnar Data in a GridView  

      2.19 Allowing Selection Anywhere Within a GridView  

      2.20 Adding a Delete Confirmation Pop-Up  

      2.21 Displaying a Pop-Up Details Window  

      2.22 Adding a Totals Row to a GridView  

3. Validation

      3.1 Requiring That Data Be Entered in a Field  

      3.2 Requiring Data to Be in a Range  

      3.3 Requiring That Two Data Input Fields Match  

      3.4 Requiring Data to Match a Predefined Pattern  

      3.5 Requiring That a Drop-Down List Selection Be Made  

      3.6 Requiring Data to Match a Database Entry  

      3.7 Using Validation Groups to Support Login and New User Registration Within a Single Form  

      3.8 Performing Validation Programmatically to Execute Your Own Application-Specific Logic  

4. Forms

      4.1 Setting the Default Button to Submit a Form  

      4.2 Submitting a Form to a Different Page  

      4.3 Simulating Multipage Forms  

      4.4 Setting the Initial Focus to a Specific Control  

      4.5 Setting the Focus to a Control with a Validation Error  

5. User Controls

      5.1 Sharing a Page Header on Multiple Pages  

      5.2 Creating a Customizable Navigation Bar  

      5.3 Reusing Code-Behind Classes  

      5.4 Communicating Between User Controls  

      5.5 Adding User Controls Dynamically  

6. Custom Controls

      6.1 Combining HTML Controls in a Single Custom Control  

      6.2 Creating a Custom Control with Attributes  

      6.3 Creating a Custom Control with State  

      6.4 Using the Control State with Custom Controls  

      6.5 Customizing an ASP.NET TextBox Server Control  

7. Maintaining State

      7.1 Maintaining Information Needed by All Users of an Application  

      7.2 Maintaining Information About a User Throughout a Session  

      7.3 Preserving Information Between Postbacks  

      7.4 Preserving Information Across Multiple Requests for a Page  

8. Error Handling

      8.1 Handling Errors at the Method Level  

      8.2 Handling Errors at the Page Level  

      8.3 Handling Errors at the Application Level  

      8.4 Displaying User-Friendly Error Messages  

9. Security

      9.1 Restricting Access to All Application Pages  

      9.2 Restricting Access to Selected Application Pages  

      9.3 Restricting Access to Application Pages by Role  

      9.4 Using Windows Authentication  

      9.5 Using Membership and Roles  

10. Profiles and Themes

      10.1 Using Profiles  

      10.2 Inheriting a Profile  

      10.3 Using and Migrating Anonymous Profiles  

      10.4 Managing User Profiles  

      10.5 Using Themes  

      10.6 User-Personalized Themes  

11. Web Parts

      11.1 Using Server Controls and User Controls as Web Parts  

      11.2 Creating a Reusable Web Parts Catalog  

      11.3 Creating a Custom Web Part  

      11.4 Communicating Between Web Parts  

      11.5 Persisting Personalized Web Part Properties  

12. Configuration

      12.1 Overriding Default HTTP Runtime Parameters in web.config  

      12.2 Adding Custom Application Settings in web.config  

      12.3 Displaying Custom Error Messages  

      12.4 Maintaining Session State Across Multiple Web Servers  

      12.5 Accessing Other web.config Configuration Elements  

      12.6 Adding Your Own Configuration Elements to web.config  

      12.7 Encrypting web.config Sections  

13. Tracing and Debugging

      13.1 Uncovering Page-Level Problems  

      13.2 Uncovering Application-Wide Problems  

      13.3 Pinpointing the Cause of an Exception  

      13.4 Uncovering Problems Within Web Application Components  

      13.5 Uncovering Problems Within Dual-Use Components  

      13.6 Writing Trace Data to the Event Log with Controllable Levels  

      13.7 Sending Trace Data via Email with Controllable Levels  

      13.8 Using a Breakpoint to Stop Execution of an Application When a Condition Is Met  

14. Web Services

      14.1 Creating a Web Service  

      14.2 Consuming a Web Service  

      14.3 Creating a Web Service That Returns a Custom Object  

      14.4 Setting the URL of a Web Service at Runtime  

15. Dynamic Images

      15.1 Drawing Button Images on the Fly  

      15.2 Creating Bar Charts on the Fly  

      15.3 Displaying Images Stored in a Database  

      15.4 Displaying Thumbnail Images  

16. Caching

      16.1 Caching Pages  

      16.2 Caching Pages Based on Query String Parameter Values  

      16.3 Caching Pages Based on Browser Type and Version  

      16.4 Caching Pages Based on Developer-Defined Custom Strings  

      16.5 Caching Pages Based on Database Dependencies  

      16.6 Caching User Controls  

      16.7 Caching Application Data  

      16.8 Caching Application Data Based on Database Dependencies  

      16.9 Caching Data Sources  

17. Internationalization

      17.1 Localizing Request/Response Encoding  

      17.2 Providing Multiple Language Support  

      17.3 Using Global Resources and Overriding Currency Formatting  

18. File Operations

      18.1 Downloading a File from the Web Server  

      18.2 Uploading a File to the Web Server  

      18.3 Processing an Uploaded File Without Storing It on the Filesystem  

      18.4 Storing the Contents of an Uploaded File in a Database  

19. Performance

      19.1 Reducing Page Size by Selectively Disabling the ViewState  

      19.2 Speeding Up String Concatenation with a StringBuilder  

      19.3 Speeding Up Read-Only Data Access  

      19.4 Speeding Up Data Access to a SQL Server Database Using the SQL Provider  

20. HTTP Handlers

      20.1 Creating a Reusable Image Handler  

      20.2 Creating a File Download Handler  

21. Assorted Tips

      21.1 Accessing HTTP-Specific Information from Within a Class  

      21.2 Executing External Applications  

      21.3 Transforming XML to HTML  

      21.4 Determining the User's Browser Type  

      21.5 Dynamically Creating Browser-Specific Stylesheets  

      21.6 Saving and Reusing HTML Output  

      21.7 Sending Mail  

      21.8 Dynamic Menus  

      21.9 Adding Breadcrumbs  

Index

Preface

1. Master Pages

      1.1 Generating a Quick Master/Content Page Arrangement  

      1.2 Extending a Master Page's Content to Include Content for Other Application Pages  

      1.3 Changing Which Master Page Is Used Without Modifying All Affected Application Pages  

      1.4 Setting the Master Page at Runtime  

2. Tabular Data

      2.1 Selecting the Right Tabular Control  

      2.2 Generating a Quick-and-Dirty Tabular Display  

      2.3 Enhancing the Output of a Tabular Display  

      2.4 Displaying Data from an XML File  

      2.5 Displaying an Array as a Group of Checkboxes  

      2.6 Displaying Data from a Hashtable  

      2.7 Adding Next/Previous Navigation to a DataGrid  

      2.8 Adding First/Last Navigation to a DataGrid  

      2.9 Adding Direct Page Navigation to a DataGrid  

      2.10 Sorting Data in Ascending/Descending Order Within a DataGrid  

      2.11 Combining Sorting and Paging in a DataGrid  

      2.12 Paging Through a Record-Heavy DataGrid  

      2.13 Editing Data Within a DataGrid  

      2.14 Navigating and Sorting Within a GridView  

      2.15 Updating a GridView Without Refreshing the Whole Page  

      2.16 Editing Data in a GridView  

      2.17 Inserting a Row Within a GridView  

      2.18 Formatting Columnar Data in a GridView  

      2.19 Allowing Selection Anywhere Within a GridView  

      2.20 Adding a Delete Confirmation Pop-Up  

      2.21 Displaying a Pop-Up Details Window  

      2.22 Adding a Totals Row to a GridView  

3. Validation

      3.1 Requiring That Data Be Entered in a Field  

      3.2 Requiring Data to Be in a Range  

      3.3 Requiring That Two Data Input Fields Match  

      3.4 Requiring Data to Match a Predefined Pattern  

      3.5 Requiring That a Drop-Down List Selection Be Made  

      3.6 Requiring Data to Match a Database Entry  

      3.7 Using Validation Groups to Support Login and New User Registration Within a Single Form  

      3.8 Performing Validation Programmatically to Execute Your Own Application-Specific Logic  

4. Forms

      4.1 Setting the Default Button to Submit a Form  

      4.2 Submitting a Form to a Different Page  

      4.3 Simulating Multipage Forms  

      4.4 Setting the Initial Focus to a Specific Control  

      4.5 Setting the Focus to a Control with a Validation Error  

5. User Controls

      5.1 Sharing a Page Header on Multiple Pages  

      5.2 Creating a Customizable Navigation Bar  

      5.3 Reusing Code-Behind Classes  

      5.4 Communicating Between User Controls  

      5.5 Adding User Controls Dynamically  

6. Custom Controls

      6.1 Combining HTML Controls in a Single Custom Control  

      6.2 Creating a Custom Control with Attributes  

      6.3 Creating a Custom Control with State  

      6.4 Using the Control State with Custom Controls  

      6.5 Customizing an ASP.NET TextBox Server Control  

7. Maintaining State

      7.1 Maintaining Information Needed by All Users of an Application  

      7.2 Maintaining Information About a User Throughout a Session  

      7.3 Preserving Information Between Postbacks  

      7.4 Preserving Information Across Multiple Requests for a Page  

8. Error Handling

      8.1 Handling Errors at the Method Level  

      8.2 Handling Errors at the Page Level  

      8.3 Handling Errors at the Application Level  

      8.4 Displaying User-Friendly Error Messages  

9. Security

      9.1 Restricting Access to All Application Pages  

      9.2 Restricting Access to Selected Application Pages  

      9.3 Restricting Access to Application Pages by Role  

      9.4 Using Windows Authentication  

      9.5 Using Membership and Roles  

10. Profiles and Themes

      10.1 Using Profiles  

      10.2 Inheriting a Profile  

      10.3 Using and Migrating Anonymous Profiles  

      10.4 Managing User Profiles  

      10.5 Using Themes  

      10.6 User-Personalized Themes  

11. Web Parts

      11.1 Using Server Controls and User Controls as Web Parts  

      11.2 Creating a Reusable Web Parts Catalog  

      11.3 Creating a Custom Web Part  

      11.4 Communicating Between Web Parts  

      11.5 Persisting Personalized Web Part Properties  

12. Configuration

      12.1 Overriding Default HTTP Runtime Parameters in web.config  

      12.2 Adding Custom Application Settings in web.config  

      12.3 Displaying Custom Error Messages  

      12.4 Maintaining Session State Across Multiple Web Servers  

      12.5 Accessing Other web.config Configuration Elements  

      12.6 Adding Your Own Configuration Elements to web.config  

      12.7 Encrypting web.config Sections  

13. Tracing and Debugging

      13.1 Uncovering Page-Level Problems  

      13.2 Uncovering Application-Wide Problems  

      13.3 Pinpointing the Cause of an Exception  

      13.4 Uncovering Problems Within Web Application Components  

      13.5 Uncovering Problems Within Dual-Use Components  

      13.6 Writing Trace Data to the Event Log with Controllable Levels  

      13.7 Sending Trace Data via Email with Controllable Levels  

      13.8 Using a Breakpoint to Stop Execution of an Application When a Condition Is Met  

14. Web Services

      14.1 Creating a Web Service  

      14.2 Consuming a Web Service  

      14.3 Creating a Web Service That Returns a Custom Object  

      14.4 Setting the URL of a Web Service at Runtime  

15. Dynamic Images

      15.1 Drawing Button Images on the Fly  

      15.2 Creating Bar Charts on the Fly  

      15.3 Displaying Images Stored in a Database  

      15.4 Displaying Thumbnail Images  

16. Caching

      16.1 Caching Pages  

      16.2 Caching Pages Based on Query String Parameter Values  

      16.3 Caching Pages Based on Browser Type and Version  

      16.4 Caching Pages Based on Developer-Defined Custom Strings  

      16.5 Caching Pages Based on Database Dependencies  

      16.6 Caching User Controls  

      16.7 Caching Application Data  

      16.8 Caching Application Data Based on Database Dependencies  

      16.9 Caching Data Sources  

17. Internationalization

      17.1 Localizing Request/Response Encoding  

      17.2 Providing Multiple Language Support  

      17.3 Using Global Resources and Overriding Currency Formatting  

18. File Operations

      18.1 Downloading a File from the Web Server  

      18.2 Uploading a File to the Web Server  

      18.3 Processing an Uploaded File Without Storing It on the Filesystem  

      18.4 Storing the Contents of an Uploaded File in a Database  

19. Performance

      19.1 Reducing Page Size by Selectively Disabling the ViewState  

      19.2 Speeding Up String Concatenation with a StringBuilder  

      19.3 Speeding Up Read-Only Data Access  

      19.4 Speeding Up Data Access to a SQL Server Database Using the SQL Provider  

20. HTTP Handlers

      20.1 Creating a Reusable Image Handler  

      20.2 Creating a File Download Handler  

21. Assorted Tips

      21.1 Accessing HTTP-Specific Information from Within a Class  

      21.2 Executing External Applications  

      21.3 Transforming XML to HTML  

      21.4 Determining the User's Browser Type  

      21.5 Dynamically Creating Browser-Specific Stylesheets  

      21.6 Saving and Reusing HTML Output  

      21.7 Sending Mail  

      21.8 Dynamic Menus  

      21.9 Adding Breadcrumbs  

Index

商品描述(中文翻譯)

描述
這本全新修訂的《ASP.NET 食譜》針對 ASP.NET 2.0 完全更新,擁有從初學者到進階的 Windows 基礎網站開發所需的一切,使用微軟流行的 Visual Studio 2005 和 ASP.NET 2.0 開發工具。這本書是為了那些不耐煩的專業人士而寫的,《ASP.NET 2.0 食譜》包含超過 125 個食譜,幫助解決在構建基於 ASP.NET 的網頁應用程式時可能遇到的常見及不常見問題。

這本書中的食譜涵蓋從簡單的編碼技術到更全面的開發策略,採用 O'Reilly 食譜系列流行的問題-解決-討論格式。與第一版一樣,每個解決方案都以 C# 和 Visual Basic 2005 編寫。

這一新版本的新增和修訂包括:
- 三個新章節,包括 25 個新食譜,涵蓋主頁和內容頁、使用個人資料和主題的個性化、自定義網頁部件等
- 每個解決方案的新代碼,重新編寫以利用 ASP.NET 2.0 的新功能和技術,並可供下載

《ASP.NET 2.0 食譜》繼續提供最全面的內容,涵蓋:
- 表格控制,包括新的 GridView 控制
- 數據驗證,包括新的 ASP.NET 2.0 驗證控制,以及以程式化方式執行自定義驗證的技術
- 用戶和自定義控制
- 錯誤處理、性能調優和快取

目錄
前言
1. 主頁
      1.1 生成快速的主頁/內容頁佈局
      1.2 擴展主頁的內容以包含其他應用頁面的內容
      1.3 在不修改所有受影響的應用頁面的情況下更改使用的主頁
      1.4 在運行時設置主頁

2. 表格數據
      2.1 選擇合適的表格控制
      2.2 生成快速且簡單的表格顯示
      2.3 增強表格顯示的輸出
      2.4 從 XML 文件顯示數據
      2.5 將數組顯示為一組複選框
      2.6 從 Hashtable 顯示數據
      2.7 向 DataGrid 添加上一頁/下一頁導航
      2.8 向 DataGrid 添加首頁/尾頁導航
      2.9 向 DataGrid 添加直接頁面導航
      2.10 在 DataGrid 中按升序/降序排序數據
      2.11 在 DataGrid 中結合排序和分頁
      2.12 在記錄量大的 DataGrid 中進行分頁
      2.13 在 DataGrid 中編輯數據
      2.14 在 GridView 中導航和排序
      2.15 在不刷新整個頁面的情況下更新 GridView
      2.16 在 GridView 中編輯數據
      2.17 在 GridView 中插入行
      2.18 在 GridView 中格式化列數據
      2.19 允許在 GridView 中的任何地方選擇
      2.20 添加刪除確認彈出窗口
      2.21 顯示彈出詳情窗口
      2.22 向 GridView 添加總計行

3. 驗證
      3.1 要求在字段中輸入數據
      3.2 要求數據在範圍內
      3.3 要求兩個數據輸入字段匹配
      3.4 要求數據匹配預定義模式
      3.5 要求選擇下拉列表
      3.6 要求數據匹配數據庫條目
      3.7 使用驗證組支持單個表單中的登錄和新用戶註冊
      3.8 以程式化方式執行驗證以執行自定義應用邏輯

4. 表單
      4.1 設置默認按鈕以提交表單
      4.2 將表單提交到不同的頁面
      4.3 模擬多頁表單
      4.4 將初始焦點設置到特定控制
      4.5 將焦點設置到有驗證錯誤的控制

5. 用戶控制
      5.1 在多個頁面上共享頁面標題
      5.2 創建可自定義的導航欄
      5.3 重用後台代碼類
      5.4 在用戶控制之間進行通信
      5.5 動態添加用戶控制

6. 自定義控制
      6.1 在單個自定義控制中組合 HTML 控制
      6.2 創建具有屬性的自定義控制
      6.3 創建具有狀態的自定義控制
      6.4 在自定義控制中使用控制狀態
      6.5 自定義 ASP.NET TextBox 伺服器控制

7. 維護狀態
      7.1 維護應用程序所有用戶所需的信息
      7.2 在整個會話中維護有關用戶的信息
      7.3 在回發之間保留信息
      7.4 在多次請求頁面之間保留信息

8. 錯誤處理
      8.1 在方法級別處理錯誤
      8.2 在頁面級別處理錯誤
      8.3 在應用程序級別處理錯誤
      8.4 顯示用戶友好的錯誤消息

9. 安全性
      9.1 限制對所有應用頁面的訪問
      9.2 限制對選定應用頁面的訪問
      9.3 按角色限制對應用頁面的訪問
      9.4 使用 Windows 認證
      9.5 使用會員和角色

10. 個人資料和主題
      10.1 使用個人資料
      10.2 繼承個人資料
      10.3 使用和遷移匿名個人資料
      10.4 管理用戶個人資料
      10.5 使用主題
      10.6 用戶個性化主題

11. 網頁部件
      11.1 將伺服器控制和用戶控制用作網頁部件
      11.2 創建可重用的網頁部件目錄
      11.3 創建自定義網頁部件
      11.4 在網頁部件之間進行通信
      11.5 持久化個性化網頁部件屬性

12. 配置
      12.1 在 web.config 中覆蓋默認 HTTP 運行時參數
      12.2 在 web.config 中添加自定義應用設置
      12.3 顯示自定義錯誤消息
      12.4 在多個網頁伺服器之間維護會話狀態
      12.5 訪問其他 web.config 配置元素
      12.6 向 web.config 添加自己的配置元素
      12.7 加密 web.config 部分

13. 追蹤和除錯
      13.1 揭示頁面級別的問題
      13.2 揭示應用級別的問題
      13.3 確定異常的原因
      13.4 揭示網頁應用組件中的問題
      13.5 揭示雙用途組件中的問題
      13.6 以可控級別將追蹤數據寫入事件日誌
      13.7 以可控級別通過電子郵件發送追蹤數據
      13.8 使用斷點在滿足條件時停止應用程序的執行

14. 網頁服務
      14.1 創建網頁服務
      14.2 使用網頁服務
      14.3 創建返回自定義對象的網頁服務
      14.4 在運行時設置網頁服務的 URL

15. 動態圖像
      15.1 動態繪製按鈕圖像
      15.2 動態創建條形圖
      15.3 顯示存儲在數據庫中的圖像
      15.4 顯示縮略圖

16. 快取
      16.1 快取頁面
      16.2 根據查詢字符串參數值快取頁面
      16.3 根據瀏覽器類型和版本快取頁面
      16.4 根據開發者定義的自定義字符串快取頁面
      16.5 根據數據庫依賴快取頁面