ebook img

Pro ASP.NET Web Forms Techniques PDF

595 Pages·2004·21.821 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Pro ASP.NET Web Forms Techniques

Pro ASP.NET Web Forms Techniques, Second Edition ALEX HOMER APress Media, LLC Pro ASP.NET Web Forms Techniques, Second Edition Copyright ©2004 by Alex Homer Originally published by Apress in 2004 All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN 978-1-59059-317-2 ISBN 978-1-4302-0662-0 (eBook) DOI 10.1007/978-1-4302-0662-0 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Technical Reviewers: David Beauchemin, Matt Bullock, Mathew Gibbs, Praveen Hari, John Kauffman, Ajoy Krisbnamoothy, Robert Oliver, David Schultz, Kevin Spencer, Kent Tegels, Gary Vartanofl Editorial Board: Steve Anglin, Dan Appleman, Gary Cornell, James Cox, Tony Davis, John Franklin, Chris Mills, Steven Rycroft, Dominic Shakeshaft, Julian Skinner, Martin Streicher, Jim Sumser, Karen Watterson, Gavin Wray, John Zukowski Assistant Publisher: Grace Wong Project Manager: Beth Christmas Copy Editor: Anne Friedman Production Manager: Kari Brooks Production Editor: Lori Bring Proofreader: Thistle Hill Publishing Services, U.C Compositor: Kinetic Publishing Services, U.C Indexer: Rebecca Plunkett Artist: Kinetic Publishing Services, U.C Cover Designer: Kurt Krames Manufacturing Manager: 'Ibm Debolsld The information in this book is distributed on an •as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. Contents at a Glance About the Author ................................................... ix Introduction ....................................................... xi Chapter 1 Getting Started ...................................... 1 Chapter 2 Browser Compatibility with ASP.NET Server Controls ..................................... 41 Chapter 3 laying the Foundations ............................. 83 Chapter 4 The Home Page ...................................... 129 Chapter 5 Banners, Footers, and Email ...................... 177 Chapter 6 The Ancillary Pages ............................... 225 Chapter 7 Creating Graphs and Charts ....................... 283 Chapter 8 Interactive Web Forms ............................. 341 Chapter 9 The Interactive Model Details .................... 383 Chapter 10 Car Prices and Quotations ........................ 429 Chapter 11 The Login and Register Page ...................... 471 Chapter 12 Quotations and Orders ............................. 521 Index ............................................................. 563 iii Contents About the Author ................................................... ix Introduction ....................................................... xi Chapter 1 Getting Started. .................................. 1 Why ASP. NET? ........................................................ 2 Designing an Interactive Web Site ............................... 23 Summary ............................................................. 38 Chapter 2 Browser Compatibility with ASP.NET Server Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Built-In Intelligence ............................................. 42 A Test Application ............................................... 43 Viewing the Test Pages ........................................... 46 Specifying Up-level or Down-level Clients ...................... 54 list Control Formatting and Templates .......................... 57 What If There's No Client-Side Script Support? ................ 67 The ASP. NET Panel Control ........................................ 74 Don't Get Caught Out by Output Caching ......................... 78 Summary ............................................................. 81 Chapter 3 Laying the Foundations ........................ 83 Obtaining the Example Files ...................................... 83 Xrox Cars Client-Side Technical Requirements .................. 85 Checking for Sessions and Scripting Support .................. 93 Cross-Browser Compatibility Issues ............................. 105 Solving Browser Compatibility Issues .......................... 108 Making Sites Accessible to All Visitors ....................... 124 Summary ............................................................ 126 Chapter 4 The Home Page ................................... 129 The Overall Page Structure ...................................... 129 Setting the Styles for the Page ................................ 137 Providing Accessibility Navigation Aids ....................... 143 v Contents The Links to Other Pages ........................................ 149 The "News and Special Offers" Section ......................... 151 The List of Car Models .......................................... 161 Summary ............................................................ 176 Chapter 5 Banners, Footers, and Email ................ 177 About ASP. NET User Controls ..................................... 177 The Animated Page Banner ........................................ 183 The Page Footer Section ......................................... 201 Adding Users to the Mailing List ............................... 206 Summary ............................................................ 223 Chapter 6 The Ancillary Pages ........................... 225 The Structure of the Ancillary Pages .......................... 225 Choosing Static or Dynamic Content ............................. 233 The "Read News Item" Page ....................................... 238 The "Compare Models" Page ....................................... 247 Summary ............................................................ 281 Chapter 1 Creating Graphs and Charts .................. 283 Dynamically Generated Graphics and Images ................... 283 The • NET Framework Drawing Classes ............................. 290 Creating a Simple Pie Chart .................................... 293 The Vehicle Comparison Charts .................................. 319 Summary ............................................................ 338 Chapter 8 Interactive Web Forms ........................ 341 Meeting the Design Requirements ................................ 341 The Model Details Page in Outline .............................. 354 The Structure of the Model Details Page ..................... 366 Summary ............................................................ 381 Chapter 9 The Interactive Model Details ............. 383 The Data for the Model Details Page ........................... 383 The Code in the Model Details Page ............................ 398 The Model Details "Tab" Pages in Detail ....................... 403 Summary ............................................................ 426 vi Contents Chapter 10 Car Prices and Quotations ................... 429 Calculating the Price of the Vehicle .......................... 429 Calculating the Finance Terms .................................. 438 Saving the Configuration As a Quotation ....................... 447 The No-Script Version of the Page .............................. 459 Summary ............................................................ 469 Chapter 11 The Login and Register Page ................ 471 Web Site Users and Identities .................................. 471 Xrox Cars Login and Register Process .......................... 484 The Login and Register Page .................................... 492 Summary ............................................................ 518 Chapter 12 Quotations and Orders ........................ 521 Binding List Controls to Related Data ......................... 521 Building the My Cars Page ....................................... 534 Summary ............................................................ 560 Index .............................................................. 563 vii About the Author Alex Homer is a computer geek and Web developer with a pas sion for ASP.NET. Although he has to spend some time doing real work (a bit of consultancy and training, and the occasional conference session), most of his days are absorbed in playing with the latest Microsoft Web technology and then writing about it. Living in the picturesque wilderness of the Derbyshire Dales in England, he is well away from the demands of the real world-with only an Internet connection to maintain some distant representation of normality. But, hey, what else could you want from life? You can contact Alex through his software company, Stoneb room Limited: alex@stonebroom. com. ix Introduction ASP.NET MAKES IT EASY to create intemctive and intuitive interfaces for Web applica tions, and attmctive and exciting Web pages. The server-based postback architecture, combined with the comprehensive army of server controls that are provided as part of the .NET Framework, allow developers to quickly build browser-based interfaces for Web sites and Web applications-using much the same event- driven approach as in "tmdi tional" executable programs developed in languages like VISual Basic, Delphi, and C++. This is a completely new and different way of working from previous versions of ASP, and the underlying principles and workings of server-based events, which occur in response to actions made by the user in the page, can prove to be difficult to gmsp in their entirety. However, constructing ASP.NET pages, especially with some of the tools that are available or under development now, is very much easier and often less error-prone than in classic ASP. Besides, a completely server-based approach to user interaction does have its downsides. In high-latency scenarios, or over slow network connections, the need to hit the server every time the page content needs to be modified can intrude on the workings of an application or reduce the perceived responsiveness of a Web site. Although the ASP.NET philosophy tends to engender a server-based mechanism, where postbacks to the server are used to generate and update the pages, some of the server controls (notably the Validation controls) also encompass client-side intemc tivity through ]Script that is sent to the client for execution there. And there is no reason why a developer cannot add to this functionality for other controls by han dling client- side events in the same way as has become the norm in most Web sites and Web applications today. What Is This Book About? So, based on the title and the preceding preamble, you can safely assume that this book aims to examine the possibilities for developing user interfaces that are driven by ASP.NET. It attempts to discuss and explore a range of techniques and approaches predominantly for creating Web sites and Web pages that are as follows: • Intuitive and easy to use • Attractive and full-featured • Interactive where this is appropriate • Based (loosely) on real-world scenarios • Able to fulfill a predefined set of design requirements • Fun, memorable, and provide user satisfaction xi Introduction The example pages are, for the most part, elements of an overall application that while being somewhat optimistic as regards consumer buying patterns-form the basis for the kind ofWeb site/ application that is becoming one of the basic ingredients of the World Wide Web today. I'll be building a site that allows the user to choose, customize, and purchase a new car or truck from the world-famous Xrox Car Company. To do so, I focus on the steps of requirements-analysis and design (though not in extreme detail), followed by planning and mapping out the site. While this seems like the natural way to get started, it's often skimped on or even omitted, thereby allowing a site to develop in a haphazard and unpredictable way. While this is not always cate gorically wrong. it does make site development and maintenance that much more difficult. Even the most simplistic starting plan can reduce development and mainte nance time, as well as avoiding many common frustrations that result from the "no plan'' approach. Once the basic design in is place you'll see the development of the various resources that make up the complete site. Of course, repetition is commonplace in a Web site, and so to make the book as useful as possible I've taken some liberties to try and cover as many useful topics as possible. It means that you will look at a range of things, such as the following: • A central "Home page" that makes navigating the whole site easy • How to display the products available from the site from a back-end database • Interactive content that is driven either by server-side or client-side code, or both • Creating graphics on the fly and animations to liven up the site • A "login'' feature that recognizes users and provides optional personalization • An online order facility with order tracking and status reports via email • Some ASP.NET development tools that are available now, or are on the way What I won't be doing is concentrating on the back-end data processing tasks in any more detail than I need to in order to get the site running. On the grounds that I don't have thousands of pages available here, this book concentrates on the user interfaces, and on using fairly simple data access techniques. Of course, that doesn't mean I won't be doing it "properly," it just means that you won't see detailed discus sions of the workings of all of the .NET data access classes, or the long diatribes on catching and reporting concurrency errors. All ASP. NET code you see listed in the book, with the exception of simple abstract snippets that demonstrate a specific principle or just show the syntax, is available for download in both VB .NET and C#. The listings you see in the book are mostly written using VB .NET syntax, but they avoid the use oflanguage-specific fea tures wherever possible, so that the code can easily be converted to other languages by any reasonably capable developer who prefers to work in a different language. Where there is an obvious difference between VB .NET and C# in the way that a specific feature xii

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.