HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
The second edition of ASP.NET Unleashed further strengthens a book that is already one of the most highly regarded ASP.NET books available. Stephen covers virtually all relevant features of ASP.NET. In addition, all samples will now be presented in VB .NET and C#.
Throughout the more than 1,400 pages readers are shown how to develop state-of-the-art Web applications using Microsoft's powerful ASP.NET. It progresses through Web Forms basics, advanced page development, ADO.NET and XML, securing Web applications, XML Web Services, leveraging the .NET Framework, building custom controls and powerful sample applications. This is a resource that will be referenced over and over.
Performing Form Validation with Validation Controls
Performing Form Validation with Validation Controls
Introduction.
I. WORKING WITH ASP.NET WEB FORMS.
1. Building ASP.NET Pages.ASP.NET and the .NET Framework.
The .NET Framework Class Library. Understanding Namespaces. Standard ASP.NET Namespaces. .NET Framework-Compatible Languages.
Introducing ASP.NET Controls.
A Simple ASP.NET Page. Benefits of ASP.NET Controls. Overview of ASP.NET Controls.
Adding Application Logic to an ASP.NET Page.
Handling Control Events. Handling Page Events.
The Structure of an ASP.NET Page.
Directives. Code Declaration Blocks. ASP.NET Controls. Code Render Blocks. Server-side Comments. Server-side Include Directives. Literal Text and HTML Tags.
Summary.
2. Building Forms with Web Server Controls.Building Smart Forms.
Using Label Controls. Using the TextBox Control. Using Button Controls. Using the RadioButton and RadioButtonList Controls. Using the CheckBox and CheckBoxList Controls. Using the DropDownList Control. Using the ListBox Control.
Controlling Page Navigation.
Submitting a Form to a Different Page. Using the Redirect() Method. Working with the HyperLink Control.
Applying Formatting to Controls.
Base Web Control Properties. Applying Styles to Web Controls.
Summary.
3. Performing Form Validation with Validation Controls.Using Client-side Validation.
Configuring Client-side Validation. Enabling and Disabling Client-side Validation.
Requiring Fields: The RequiredFieldValidator Control.
Comparing to an Initial Value.
Validating Expressions: The RegularExpressionValidator Control.
Validating E-Mail Addresses. Validating Usernames and Passwords. Validating Phone Numbers. Validating Web Addresses. Checking for Entry Length. Validating ZIP Codes.
Comparing Values: The CompareValidator Control.
Comparing the Value of One Control to the Value of Another. Comparing the Value of a Control to a Fixed Value. Performing a Data Type Check.
Checking for a Range of Values: The RangeValidator Control. Summarizing Errors: The ValidationSummary Control.
Displaying Pop-Up Error Messages.
Performing Custom Validation: The CustomValidator Control.
Validating Credit Card Numbers.
Disabling Validation. Summary.
4. Advanced Control Programming.Working with View State.
Disabling View State. Adding Values to View State.
Displaying and Hiding Content.
Using the Visible and Enabled Properties. Using the Panel Control. Simulating Multipage Forms. Adding Controls Programmatically. Adding Controls to a Page. The PlaceHolder Control. Dynamically Generating Forms. Dynamically Generating List Items.
Using Rich Controls.
Displaying Interactive Calendars with the Calendar Control. Rendering Calendar Days. Displaying Banner Advertisements with the AdRotator Control. Accepting File Uploads with the HTMLInputFile Control.
Summary.
II. ADVANCED ASP.NET PAGE DEVELOPMENT.
5. Creating Custom Controls with User Controls.Including Standard Content with User Controls. Exposing Properties and Methods in User Controls. Exposing Web Controls in User Controls. Exposing Events in User Controls. Loading User Controls Programmatically. Summary.
6. Separating Code from Presentation.Creating Business Components.
Creating a Simple Business Component.
Creating Multitiered Web Applications. Using Code-Behind.
How Code-Behind Really Works. Compiling Code-Behind Files. Inheriting Multiple Pages from a Code-Behind File. Compiling a Complete ASP.NET Page.
Summary.
7. Targeting Mobile Devices with Mobile Controls.Introduction to Mobile Devices. Using Mobile Device Software Simulators. Using ASP.NET Mobile Controls.
Creating Mobile Forms. Dynamically Activating a Mobile Form. Displaying Text. Displaying Lists. Creating Text Boxes. Validating User Input. Displaying Images. Placing Phone Calls. Displaying Advertisements with Mobile Controls. Displaying Calendars with Mobile Controls.
Creating Cross-Device-Compatible Mobile Pages.
Detecting Mobile Capabilities. Choosing Devices with DeviceSpecific. Using Form Template Sets.
Summary.
8. Additional Samples and Controls.Using the Microsoft Internet Explorer WebControls.
Using the TreeView Control. Using the Toolbar Control. Using the TabStrip Control.
Using the ASP.NET Starter Kits.
The ASP.NET Community Starter Kit. The ASP.NET Reports Starter Kit. The ASP.NET Time Tracker Starter Kit. The ASP.NET Commerce Starter Kit. The ASP.NET Portal Starter Kit.
Summary.
III. Working with ADO.NET.
9. Introduction to ADO.NET.An Overview of ADO.NET. Performing Common Database Tasks.
Opening a Database Connection. Retrieving Records from a Database Table. Using Parameters with Queries. Adding Records to a Database. Updating Database Records. Deleting Database Records.
Improving Database Performance.
Using SQL Stored Procedures. Retrieving Return Values and Output Parameters. Executing Complex Stored Procedures. Improving Performance with Connection Pooling.
Advanced Database Topics.
Executing Database Commands in a Transaction. Specifying a Command Behavior. Retrieving Table Schema Information.
Summary.
10. Binding Data to Web Controls.Overview of Data Binding. Binding a Server Control to a Data Source.
Binding to the Repeater Control. Using Templates. View State and the Repeater Control. Binding to the DropDownList Control. Binding to the RadioButtonList Control. Binding to the CheckBoxList Control. Binding to a ListBox Control. Binding to Other Controls.
Creating Master/Detail Forms.
Creating Single-Page Master/Detail Forms. Creating Multipage Master/Detail Forms.
Data Binding without Data Binding Expressions. Summary.
11. Using the DataList and DataGrid Controls.Overview of the DataList and DataGrid Controls.
Understanding Event Bubbling. Using Templates. Using the DataKeys Collection.
Using the DataList Control.
Displaying Data in a DataList. Using Templates with a DataList. Using Styles with a DataList. Creating Multiple Columns in a DataList. Capturing Events Raised in a DataList Control. Selecting Items in a DataList Control. Using the DataKeys Collection with the DataList Control. Creating a Master/Detail Form with a DataList Control. Editing Items in a DataList Control.
Using the DataGrid Control.
Creating Columns in a DataGrid Control. Using Styles with a DataGrid. Sorting Columns in a DataGrid Control. Paging Through Records in a DataGrid. Selecting Rows in a DataGrid Control. Editing Items in a DataGrid Control. Editing Items in a DataGrid Control with Templates.
Summary.
12. Working with DataSets.Understanding DataSets.
Elements of DataSets. Adding DataTables to a DataSet. Binding Controls to a DataSet.
Understanding DataTables.
Creating DataTables Programmatically. Setting DataTable Properties. Setting Column Properties in a DataTable. Computing Column Values in a DataTable. Defining Relationships Between DataTables. Retrieving DataTable Schema Information. Updating Records in a DataTable.
Understanding DataViews.
Filtering Rows in a DataView. Sorting Rows in a DataView. Finding Rows in a DataView.
Using DataSets with ASP.NET Pages.
Caching DataSets. Displaying Cached Data. Filtering Cached Data. Finding a Row in a Cached DataSet.
Summary.
13. Working with XML.Overview of the XML Classes. Using XML with DataSets.
Reading an XML Document into a DataSet. Using a Schema with ReadXml. Writing an XML Document from a DataSet. Using XMLDataDocuments with DataSets.
Transforming XML with XSL Stylesheets. Using the ASP.NET Xml Control. Using the XslTransform Class. Using Strongly Typed DataSets. Summary.
14. Using ADO.NET to Create a Search Page.Using SQL Server Full-Text Search.
Configuring the Full-Text Search Service. Performing Free Text Queries with Database Data. Performing Boolean Queries with Database Data. Using the CONTAINSTABLE Function. Uploading and Indexing Binary Documents.
Using the Microsoft Indexing Service.
Configuring the Microsoft Indexing Service. Connecting to Microsoft Indexing Service. Retrieving Document Properties. Performing Free Text Queries with File System Data. Performing Boolean Queries with File System Data. Performing Queries with Document Properties.
Summary.
IV. WORKING WITH ASP.NET APPLICATIONS.
15. Creating ASP.NET Applications.Overview of ASP.NET Applications. Using Application State.
Understanding Application State and Synchronization. Using the Global.asax File. Understanding Context and Using the Global.asax File. Handling the Application Start and Init Events. Handling the Application_BeginRequest Event.
Using the Web.Config File.
Examining the Configuration Sections. Modifying Configuration Settings. Setting the Configuration Location. Locking Configuration Settings. Adding Custom Configuration Information.
Using HTTP Handlers and Modules.
Working with HTTP Handlers. Working with HTTP Modules. Creating the WhosOn Application.
Summary.
16. Tracking User Sessions.Using Browser Cookies.
How Cookies Work. Creating and Reading Session Cookies. Creating and Reading Persistent Cookies. Setting Cookie Properties. Examining Limitations of Cookies.
Using Session State.
Adding Items to Session State. Removing Items from Session State. Starting a User Session. Ending a User Session. Handling Session Events. Storing Session State in Process. Storing Session State in a Windows Service. Storing Session State in a Database Table. Disabling Session State.
Using Cookieless Sessions.
Enabling Cookieless Sessions. Examining Limitations of Cookieless Sessions.
Summary.
17. Caching ASP.NET Applications.Using Page Output Caching.
Varying Cache Contents by Parameter. Varying Cache Contents by Header. Varying the Cache Contents by a Custom String. Setting the Cache Location. Working with the HttpCachePolicy Class.
Using Page Fragment Caching.
Varying Page Fragment Caching by Parameter. Examining the Limitations of Page Fragment Caching.
Using Page Data Caching.
Adding Items to the Cache. Adding Cache File Dependencies. Adding Cache Trigger Dependencies. Adding Cache Key Dependencies. Creating an Absolute Expiration Policy. Creating a Sliding Expiration Policy. Setting Cache Item Priorities. Creating a Cache Callback Method.
Summary.
18. Application Tracing and Error Handling.Responding to Errors.
Viewing Error Information. Page-Level Error Handling. Application-Level Error Handling.
Tracing and Monitoring Your Application.
Tracing Page Execution. Monitoring the ASP.NET Process. Retrieving Process Information.
Logging Events.
Using Performance Counters.
Using the Debugger.
Attaching the Debugger. Creating Breakpoints. Creating Watches. Stepping Through an ASP.NET Page.
Summary.
V. SECURING ASP.NET APPLICATIONS.
19. Using Forms-Based Authentication.Working with Forms Authentication.
Enabling Forms Authentication. Configuring Forms Authentication. Configuring Forms Authorization. Retrieving User Information. Creating a Sign-Out Page. Authenticating Users with the Web.Config File. Authenticating Users with an XML File. Authenticating Users with a Database Table. Implementing Roles-based Authentication. Creating a Custom Authentication Ticket. Using Forms Authentication and Web Farms.
Working with Passport Authentication.
Enabling Passport Authentication. Retrieving User Information.
Summary.
20. Using Windows-Based Authentication.Working with Windows Authentication.
Configuring Internet Information Server Security. Configuring Microsoft Windows Security. Configuring Windows Authentication. Configuring Windows Authorization. Configuring Custom Roles. Retrieving User Information.
Impersonating User Accounts.
Executing ASP.NET Pages under a User Account.
Setting Security Policies. Summary.
21. Encrypting Data over the Network.Using the Secure Sockets Layer.
Encryption. Authentication. Data Integrity. How Secure Is SSL?
Configuring Your Server to Use SSL.
Generating a Certificate Request File. Applying for a Server Certificate. Installing Your Server Certificate.
Using SSL in ASP.NET Pages. Using .NET Encryption Classes.
Using Hash Algorithms. Using Symmetric Encryption Algorithms. Using Asymmetric Encryption.
Summary.
VI. BUILDING ASP.NET WEB SERVICES.
22. Creating an XML Web Service.Overview of XML Web Services.
XML Web Services Facilitate Communication. XML Web Services Enable Aggregation.
Creating a Simple XML Web Service.
Setting WebMethod Attributes. Setting WebService Attributes. Precompiling an XML Web Service.
Testing an XML Web Service from a Browser.
Invoking an XML Web Service with HTTP-Get. Invoking an XML Web Service with HTTP-Post. Invoking an XML Web Service with SOAP.
Accessing an XML Web Service Through a Proxy Class.
Generating an XML Web Service Proxy Class. Using an XML Web Service Proxy Class. Working with the Web Services Description Language Tool. Setting Proxy Class Properties.
Transmitting Complex Data in an XML Web Service.
XML Web Services and Arrays. XML Web Services and Classes. Web Services and DataSets. Web Services and Binary Files.
Examining XML Web Service and Web Site Interaction.
XML Web Services and Application State. XML Web Services and Session State.
Summary.
23. Advanced XML Web Services.Using the WebService Behavior.
Examining Limitations of the WebService Behavior. Creating a Simple Page with a WebService Behavior. Using a WebService Behavior Callback Function. Catching Errors in a WebService Behavior. Using a WebService Behavior to Perform Partial Page Updates. Using the WebService Behavior to Retrieve Database Data.
Securing an XML Web Service.
Overview of the Secure XML Web Service. Creating the Database Tables. Creating the Login() Method. Retrieving the Custom SOAP Header. Authenticating the Session Key. Caching the Session Keys. Building the Secure XML Web Service. Accessing the Secure Web Service.
Using HTML Pattern Matching.
Creating the WSDL Document. Specifying the Regular Expression Pattern. Creating a Simple HTML Pattern Matching Service. Using Input Parameters with HTML Pattern Matching. Building the Six Degrees Web Service.
Summary.
VII. LEVERAGING THE .NET FRAMEWORK.
24. Working with Collections and Strings.Working with Collections.
Using the ArrayList Collection. Using the HashTable Collection.
Working with Strings.
Formatting Strings. Using String Methods and Properties. Using the StringBuilder Class. Appending Strings to a StringBuilder.
Working with Regular Expressions.
Using Regular Expression Classes. Examining Elements of a Regular Expression. Matching Single Characters. Matching Special Characters. Matching Alternative Sequences of Characters. Matching with Quantifiers. Identifying Regular Expressions and Greed. Capturing and Backreferences. Using Replacement Patterns. Setting Regular Expression Options.
Summary.
25. Working with the File System.Security and the File System. Using Files and Directories.
Creating and Reading Text Files. Creating and Reading Binary Files. Displaying the Contents of a Directory. Retrieving Path Information.
Using Serialization.
Using Binary Serialization. Using XML Serialization.
Summary.
26. Sending Email and Accessing the Network.Sending Email from an ASP.NET Page.
The Microsoft SMTP Service. Sending a Simple Email Message. Using the MailMessage Class. Adding Attachments to an Email Message. Sending HTML Email.
Using Message Queuing.
Configuring Microsoft Message Queuing. Working with Message Queues. Sending Messages to a Queue. Retrieving Messages from a Queue. Displaying the Body of a Message. Sending and Receiving Complex Messages.
Accessing Other Web Sites with the HTTP Protocol.
Using the WebClient Class. Using the HttpWebRequest Class. Resolving Domain Names.
Summary.
27. Creating Graphics On-the-Fly with GDI+.Building Simple Images. Drawing Objects with GDI+.
Creating a Bitmap. Working with the Graphics Object. Setting Graphics Quality. Using Colors. Using Brushes. Using Pens. Setting Pen Cap Styles. Drawing a Rectangle. Drawing a Line. Drawing an Ellipse. Drawing a Curve.
Drawing a String of Text. Building Sample GDI+ Applications.
Creating an ASP.NET Paint Application. Creating a Simple Chart Application.
Summary.
VIII. BUILDING CUSTOM ASP.NET CONTROLS.
28. Developing Custom Controls.Creating a Simple Control. Using HtmlTextWriter. Adding Properties and Methods to Controls.
Using Property Accessor Functions. Using Methods with Controls.
Parsing Inner Content. Adding Child Controls to a Control.
Creating a Custom Control Builder.
Examining Custom Controls and Events.
Adding Custom Events to a Control.
Participating in Postbacks.
Handling Postback Events.
Creating Composite Controls.
Handling Events in a Composite Control.
Inheriting from Existing Controls. Accessing the Current Context. Debugging Controls. Summary.
29. Advanced Control Development.Adding Templates to a Control.
Creating Multiple Instances of a Template. Adding Multiple Templates to a Control.
Creating DataBound Controls.
Implementing Different Data Sources. Implementing a Simple DataBound Control. Using DataBound Controls and Templates. Using DataBound Controls and State. Binding a Custom Control to a DataSet.
Using Custom Controls and Web Services.
Creating the Featured Products Web Service. Creating the Featured Products Custom Control. Displaying the Featured Products Control.
Summary.
IX. SAMPLE ASP.NET APPLICATIONS.
30. Creating a Job Site.Installing the Job Site. Creating the Home Page. Authenticating Users. Creating Vanity URLs. Listing and Updating Jobs. Creating the Jobs XML Web Service. Summary.
31. Creating an Online Store.Overview of the ASP.NET Unleashed Sample Store. Installing the ASP.NET Unleashed Sample Store. Building the Navigation System. Caching the Product Data. Building the Shopping Cart. Dynamically Loading Product Templates.
Using the LoadControl Method. The Code-Behind Product Template.
Summary.
X. APPENDIXES.
Appendix A. Migrating from ASP to ASP.NET.ASP.NET Pages End with the Extension .aspx. Option Explicit Is On by Default. No More Variants. Use Parentheses When Passing Parameters to Subroutines and Methods. Functions and Subroutines Must Be Declared in <Script> Tags. Parameters Are Passed by Value. Forms Should Post Back to the Same Page. Only One Server-Side Form per Page. Don't Use Set and Let When Working with Objects. Apartment-Threaded Components Are Not Supported. No Nonindexed Default Properties. ASP.NET Pages Can Contain Only a Single Language. Differences in Request, Request.Form, and Request.QueryString.
Appendix B. HTML Control Reference.The book companion CD-ROM is missing C# code from Chapter 28 - 71 kb - Chapter28CSharpCode.zip