Tài liệu Beginning ASP.NET 1.1 with Visual C#® .NET 2003

Thảo luận trong 'Lập Trình' bắt đầu bởi Thúy Viết Bài, 5/12/13.

  1. Thúy Viết Bài

    Thành viên vàng

    Bài viết:
    198,891
    Được thích:
    172
    Điểm thành tích:
    0
    Xu:
    0Xu
    Introduction xxi
    Chapter 1: Getting Started with ASP.NET 1

    What Is a Static Web Page? 2
    How Are Static Web Pages Served? 3
    Limitations of Static Web Pages 4
    What Is a Web Server? 5
    How Are Dynamic Web Pages Served? 6
    Client-Side Dynamic Web Pages 6
    Server-Side Dynamic Web Pages 7
    What Is ASP.NET? 9
    How Does ASP.NET Differ from ASP? 9
    Using C# with ASP.NET 10
    I'm Still Confused about ASP, ASP.NET, and C# 11
    The Installation Process 11
    Which Operating System Do You Have? 11
    Prerequisites for Installing ASP.NET 12
    Try It Out Installing MDAC 2.8 13
    Installing ASP.NET and the .NET Framework 13
    Try It Out Installing the .NET Framework Redistributable 14
    Installing Web Matrix 15
    Try It Out Installing Web Matrix 16
    Configuring Web Matrix to Run with .NET Framework 1.1 18
    Try It Out Configuring Web Matrix 18
    Running Web Matrix and Setting Up the Web Server 19
    Try It Out Starting the Web Server 19
    ASP.NET Test Example 25
    Try It Out Your First ASP.NET Web Page 25
    ASP.NET Troubleshooting 28
    Page Cannot Be Displayed: HTTP Error 403 29
    Page Cannot Be Found: HTTP Error 404 30
    Web Page Unavailable While Offline 31
    I Just Get a Blank Page 31
    The Page Displays the Message But Not the Time 31
    I Get an Error Statement Citing a Server Error 32
    I Have a Different Problem 33
    Summary 33
    x
    Contents
    Chapter 2: Anatomy of an ASP.NET Page 35
    What Is .NET? 35
    From Your Code to Machine Code 37
    Introducing Two Intermediate Languages 37
    Objects 38
    The .NET Base Classes 39
    The Class Browser 40
    How ASP.NET Works 41
    Saving Your ASP.NET Files with an ASPX Suffix 42
    Inserting ASP.NET Code into Our Web Pages 42
    Try It Out Inserting Server-Side (ASP.NET) Code 44
    Try It Out Interweaving ASP.NET Output with HTML 49
    ASP.NET in Action 51
    Binding to a Database 51
    Try It Out Binding to a Database 51
    Binding to a Simple XML File 54
    Try It Out Binding to a Simple XML Document 54
    Summary 57
    Exercises 58
    Chapter 3: Server Controls and Variables 59
    Forms 60
    Web Pages, HTML Forms, and Web Forms 60
    Request and Response in Non-ASP.NET Pages 61
    Where ASP.NET Fits in with the .NET Framework 63
    The <form> Tag in ASP.NET 64
    Using ASP.NET Server Controls 64
    <asp:Label> 65
    Try It Out Using the <asp:Label> Control 67
    Modifying ASP.NET Controls 68
    <aspdata:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEXh5PJm+yKVAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=" class="mceSmilieSprite mceSmilie8" alt=":D" title="Big Grin :D">ropDownList> 69
    Try It Out Using the <asp[IMG]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEXh5PJm+yKVAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=" class="mceSmilieSprite mceSmilie8" alt=":D" title="Big Grin :D">ropDownList> Control 69
    <asp:ListBox> 73
    Try It Out Using the <asp:ListBox> Control 73
    <asp:TextBox> 75
    Try It Out Using the <asp:TextBox> Control 75
    <asp:RadioButtonList> and <asp:RadioButton> 77
    Try It Out Using the <asp:RadioButtonList> Control 78
    <asp:CheckBox> and <asp:CheckBoxList> 79
    Try It Out Using the <asp:CheckBox> Control 80
    Storing Information in C# Variables 82
    Declaring Value Type Variables 82
    Try It Out Using Variables 83
    Datatypes 86
    Numeric 86
    Text Datatypes 88
    Other Datatypes 89
    Naming Variables 90
    xi
    Contents
    Variable Scope 91
    Try It Out Creating Block and Function-Level Variables 92
    Constants 97
    Conversion Functions 97
    Arrays 98
    Try It Out Using Arrays 99
    Data Collections 103
    ArrayList 103
    Try It Out Using an ArrayList 105
    Hashtables 106
    Try It Out Using Hashtables 108
    SortedList 110
    Summary 111
    Exercises 112
    [B]Chapter 4: Control Structures and Procedural Programming 113[/B]
    Operators 113
    Assignment Operator 114
    Arithmetic Operators 114
    Try It Out Tax Calculator Using Arithmetic Operators 115
    String Concatenation 118
    Numeric Comparison Operators 119
    Logical Operators 120
    Try It Out Tax Calculator Using Logical Operators 122
    Control Structures 125
    Overview of Branching Structures 125
    Overview of Looping Structures 126
    Overview of Jumping Structures 126
    Uses of Control Structures 127
    Branching Structures 128
    The if Structure 129
    Try It Out Using the if Structure 134
    The switch Structure 138
    Try It Out Using the switch Structure 141
    Looping Structures 144
    The for Loop Structure 144
    Try It Out Using the for Loop 146
    The while Loop 148
    Try It Out Using the while Loop 150
    The do .while Structure 151
    Try It Out Using do .while 152
    The foreach .in Loop 155
    Summary 156
    Exercises 157
    [B]Chapter 5: Functions 159[/B]
    Overview 159
    Modularization 160
    xii
    Contents
    Defining and Using Functions 161
    Try It Out Defining and Using a Simple Function 161
    Passing Parameters to Functions 164
    Try It Out Functions with Parameters 165
    Web Controls as Parameters 169
    Try It Out Using Web Controls as Parameters 170
    Return Values 173
    Using Return Values in Your Code 173
    Try It Out Handling Function Return Types 175
    Value, Reference, and Out Parameters 181
    Try It Out Using Value, Reference, and Out Parameters 183
    Modularization Best Practices 188
    Summary 189
    Exercises 190
    [B]Chapter 6: Event-Driven Programming and Postback 191[/B]
    What Is an Event? 192
    What Is Event-Driven Programming? 192
    HTML Events 193
    ASP.NET's Trace Feature 195
    ASP.NET Page Events 197
    ASP.NET Web Control Events 199
    Try It Out Creating Event Handlers with Web Matrix 201
    Event-Driven Programming and Postback 202
    Try It Out Reacting to Events in HTML and ASP.NET 203
    The IsPostBack Test 205
    Try It Out Calculator 206
    Summary 211
    Exercises 212
    [B]Chapter 7: Objects 215[/B]
    Classes and Instances 216
    Properties, Methods, and Events 216
    Objects in .NET 216
    Why Use Objects? 217
    Defining Classes 218
    Try It Out Creating a Class 218
    Property Variables 223
    Property Types 224
    Try It Out Read-Only Properties 224
    Initializing Objects 226
    Try It Out Overloading a Constructor 226
    Implementing Methods 227
    Try It Out Adding Methods to a Class 227
    Consolidating Overloaded Methods 230
    Advanced Classes 231
    xiii
    Contents
    Shared or Static Properties and Methods 231
    Inheritance 232
    Try It Out Inheritance 233
    Interfaces 237
    Try It Out Creating an Interface 238
    .NET Objects 243
    Namespaces 243
    The Class Browser 243
    Summary 245
    Exercises 245
    [B]Chapter 8: Reading from Databases 247[/B]
    Understanding Databases 247
    Tables 248
    Normalization 249
    SQL and Stored Procedures 251
    The Web Matrix Data Explorer 251
    Try It Out Connecting to a Database 251
    Creating Data Pages 253
    Displaying Data Using the Data Explorer 253
    Try It Out Creating a Grid 253
    Displaying Data Using the Web Matrix Template Pages 256
    Try It Out Creating a Data Page 257
    Displaying Data Using the Code Wizards 262
    Try It Out Creating a Data Page 262
    ADO.NET 269
    The OleDbConnection Object 271
    The OleDbCommand Object 271
    Try It Out Using Parameters 273
    The OleDataAdapter Object 278
    The DataSet Object 278
    The DataReader Object 278
    Try It Out Using a DataReader 279
    Summary 281
    Exercises 281
    [B]Chapter 9: Advanced Data Handling 283[/B]
    More Data Objects 283
    The DataTable Object 284
    The DataRow Object 285
    Try It Out The DataTable and DataRow Objects 286
    Updating Databases 288
    ADO.NET versus ADO 289
    Updating Data in a DataSet 289
    Try It Out Adding, Editing, and Deleting Rows 289
    Updating the Original Data Source 297
    Try It Out Auto-Generated Commands 298
    Updating the Database 301
    xiv
    Contents
    Try It Out Updating the Database 302
    Updating Databases Using a Command 307
    Try It Out Executing Commands Directly 307
    Summary 310
    Exercises 311
    [B]Chapter 10: ASP.NET Server Controls 313[/B]
    The Wrox United Application 314
    ASP.NET Web Controls 315
    HTML Server Controls 316
    HTML Server Controls versus Web Controls 318
    Web Controls 319
    Rich Object Model 320
    Automatic Browser Detection 320
    Properties 320
    Events 322
    Try It Out Creating an Event Handler 322
    Page Lifecycle 324
    Page_Load() 325
    Event Handling 326
    Page_Unload() 326
    Understanding Web Controls: The Wrox United Application 327
    Try It Out Wrox United Main Page – Default.aspx 328
    Intrinsic Controls 331
    Try It Out Wrox United – Teams.aspx 332
    Data Rendering Controls 340
    Try It Out Wrox United – Teams.aspx, Part 2 343
    Rich Controls 352
    Try It Out Wrox United – Default.aspx, Part 2, the Event Calendar 354
    Try It Out Wrox United – Displaying Fixture Details 360
    Web Matrix Controls 366
    Try It Out Wrox United – Players.aspx and the Web Matrix MX DataGrid 367
    Validation Controls 372
    Try It Out Wrox United – Registering for Email Updates (Default.aspx) 373
    Summary 378
    Exercises 378
    [B]Chapter 11: Users and Applications 381[/B]
    Remembering Information in a Web Application 382
    Cookies 383
    Try It Out Using Cookies 386
    Sessions 393
    Try It Out Using Session State 395
    Applications 404
    How Do Applications Work? 405
    Try It Out Using Application State 405
    Reacting to Application and Session Events 410
    Global.asax 410
    Try it Out Global.asax – Global Settings 411
    Caching 413
    Try It Out Wrox United – Caching Objects 415
    State Management Recommendations 418
    When to Use Cookies 419
    When to Use Sessions 419
    When to Use Applications 419
    When to Use Caching 419
    Other State Management Techniques 420
    Using Multiple State Management Techniques on a Page 421
    Try it Out Wrox United – Adding Some Style! 421
    Summary 429
    Exercises 430
    [B]Chapter 12: Reusable Code for ASP.NET 431[/B]
    Encapsulation 431
    Components 432
    Why Use Components? 434
    Applying Component Theory to Applications 434
    User Controls 435
    Try It Out Our First User Control 437
    Try It Out Wrox United – Header Control 440
    Try It Out Wrox United – Navigation User Control 446
    Code-Behind 451
    Try It Out Our First Code-Behind File 452
    Try It Out Using Code-Behind in Wrox United 457
    Summary 459
    Exercises 459
    [B]Chapter 13: .NET Assemblies and Custom Controls 463[/B]
    Three-Tier Application Design 464
    ASP.NET Application Design 465
    .NET Assemblies 466
    Try It Out Our First ASP.NET Component 467
    What Is Compilation? 470
    Try It Out Compiling Our First ASP.NET Component 470
    Accessing a Component from within an ASP.NET Page 474
    Try It Out Using a Compiled Component 474
    XCopy Deployment 476
    Accessing Assemblies in Other Locations 477
    Writing Code in Other Languages 477
    Try It Out Writing a Component in VB.NET 478
    Data Access Components 482
    Try It Out Encapsulating Data Access Code in a Component 482
    Custom Server Controls 489
    What Are Custom Controls? 490
    Try It Out Our First ASP.NET Custom Control 491
    Composite Custom Controls 499
    xvi
    Contents
    Try It Out Wrox United – Custom Composite Control 499
    Summary 506
    Exercises 507
    [B]Chapter 14: Debugging and Error Handling 509[/B]
    A Few Good Habits 510
    Tips on Coding 510
    Indent Your Code 511
    Structure Your Code 511
    Comment Your Code 512
    Convert Variables to the Correct Data Types (Validation) 512
    Try to Break Your Code 513
    Sources of Errors 514
    Syntax Errors 514
    Try It Out Syntax Error 515
    Try It Out Generate a Compiler Error 516
    Logical (Runtime) Errors 518
    Try It Out Generate a Runtime Error 519
    Try It Out Catching Illegal Values 521
    Try It Out Using RequiredFieldValidator 524
    System Errors 525
    Finding Errors 525
    Try It Out Viewing the Call-Stack 526
    Debug Mode 527
    Try It Out Disable the Debug Mode 527
    Tracing 529
    Try It Out Enabling Trace at the Page Level 529
    Try It Out Writing to the Trace Log 532
    Handling Errors 535
    Try It Out Using try .catch .finally 542
    Try It Out Using Page_Error() 548
    Error Notification and Logging 550
    Try It Out Creating Error Pages 551
    Writing to the Event Log 553
    Try It Out Writing to the Windows Error Log 554
    Mailing the Site Administrator 557
    Summary 559
    Exercises 559
    [B]Chapter 15: Configuration and Optimization 561[/B]
    Configuration Overview 562
    Browsing .config Files 562
    The Configuration Files 564
    The Structure of the Configuration Files 567
    Performance Optimization 574
    Caching 574
    Try It Out Output Caching 576
    The Cache Object 578
    Expiring Information in the Cache 581
    Try It Out Creating a File Dependency 582
    Try It Out Creating a Key Dependency 586
    Tips and Tricks 590
    Summary 591
    Exercises 591
    [B]Chapter 16: Web Services 593[/B]
    What Is a Web Service? 594
    Try It Out Creating Our First Web Service 595
    HTTP, XML, and Web Services 598
    HTTP GET 599
    HTTP POST 600
    Simple Object Access Protocol (SOAP) 601
    Building an ASP.NET Web Service 603
    Processing Directive 603
    Namespaces 603
    Public Class 604
    Web Methods 604
    Try It Out Creating a Web Service with Multiple Web Methods 605
    Testing Your Web Service 607
    Try It Out Conversions Test Page 607
    Using Your Web Service 608
    Try It Out Viewing the WSDL Contract 609
    Try It Out ISBN Search Web Service 610
    Consuming a Web Service 613
    How Does a Proxy Work? 613
    Creating a Proxy 615
    Try It Out Accessing the ISBN Web Service from an ASP.NET Page 615
    Creating a Web Service for the Wrox United Application 618
    Try It Out Adding a Results Page 619
    Try It Out Creating the Web Service 621
    Web Service Discovery 626
    Securing a Web Service 627
    Username-Password Combination or Registration Keys 627
    Try It Out Securing a Web Service with Username and Password 627
    Secure Sockets Layer (SSL) 630
    IP Address Restriction 630
    Web Services Enhancements (WSE) 631
    Other Web Services Considerations 631
    Network Connectivity 631
    Asynchronous Method Calls 631
    Service Hijacking (or Piggybacking) 632
    Provider Solvency 633
    The Interdependency Scenario 633
    Summary 633
    Exercises 634
    [B]Chapter 17: ASP.NET Security 635[/B]
    What Is Security? 636
    The ASP.NET Security Model 636
    Authentication 637
    Implementing Forms-Based Authentication 638
    Try It Out Forms-Based Authentication 639
    Forms-Based Authentication Using a Database 646
    Try It Out Authenticating against a Database 646
    Authorization 650
    Try It Out Authorization for <a class="__cf_email__" href="http://www.cloudflare.com/email-protection" data-cfemail="8edbfdebfccec3f7cae1e3efe7e0a0ede1e3">[email protected]<script type="text/javascript">
    (function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute(data-cfemail);if(a){s=;r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
    651
    Authentication in Wrox United 653
    Try It Out Adding a Login Page to WroxUnited 653
    Encryption Using SSL 664
    Try It Out Enabling SSL 665
    Summary 666
    Exercises 666
    [B]Appendix A: Exercise Solutions 667[/B]
    Chapter 2 667
    Chapter 3 669
    Chapter 4 672
    Chapter 5 675
    Chapter 6 678
    Chapter 7 681
    Chapter 8 684
    Chapter 9 686
    Chapter 10 688
    Chapter 11 693
    Chapter 12 697
    Chapter 13 702
    Chapter 14 708
    Chapter 15 713
    Chapter 16 715
    Chapter 17 720
    [B]Appendix B: Web Matrix Quick Start 725[/B]
    What Is Web Matrix? 725
    Starting ASP.NET Web Matrix 727
    The Screen 727
    How to Enter Code 730
    Try It Out Code Entry 731
    Saving and Viewing Pages 731
    Try It Out Formatting Modes, Views, and Serving Pages 733
    Reusing Code 735
    Try It Out Saving and Using Snippets 735
    Class Browser 735
    Try It Out Class Browser Property Look-Up 736
    What to Study Next 738
    Summary 738
    [B]Appendix C: The Wrox United Database 741[/B]
    The Database Design 741
    Players 742
    Status 742
    Teams 743
    PlayerTeams 743
    Positions 744
    Games 744
    GameTypes 745
    Locations 745
    Opponents 746
    Fans 746
    Installing the Database 747
    Installing the Access Database 747
    Installing the MSDE Database 747
    [B]Appendix D: Web Application Development Using Visual Studio .NET 753[/B]
    Creating a Web Application Project 754
    Features of the Visual Studio .NET Environment 755
    Visual Studio .NET Solutions and Projects 756
    Files in a Web Application Project 757
    Working with Web Pages 757
    Compiling and Running Pages 761
    Adding Code to the Code-Behind Class 762
    Features of Code View 763
    Adding Code to Methods 763
    Styling Controls and Pages in Visual Studio .NET 769
    Working in HTML View 776
    Creating User Controls 777
    Formatting Blocks of Code 782
    Developing the User Control 784
    Creating an XML File 786
    Adding a User Control to a Page 789
    Adding Custom Classes 791
    Working with Databases Using the Server Explorer 794
    Debugging in Visual Studio .NET 797
    Using Breakpoints 798
    Fixing Design-Time Errors 799
    Suggested Exercises and Further Reading 801
    [B]Appendix E: Installing and Configuring IIS 803[/B]
    Try It Out Locating and Installing IIS on Your Web Server Machine 803
    Working with IIS 806
    The Microsoft Management Console (MMC) 806
    Testing Your Installation 807
    Identifying Your Web Server's Name 807
    Managing Directories on Your Web Server 808
    Try It Out Creating a Virtual Directory and Setting Up Permissions 810
    Permissions 814
    Browsing to a Page on Your Web Server 818
    Index 825
     

    Các file đính kèm:

Đang tải...