Apress Pro ASP.NET 2.0 in VB 2005 (2006).pdf

(22684 KB) Pobierz
Pro ASP.NET 2.0
in VB 2005
Special Edition
Laurence Moroney
and Matthew MacDonald (Ed.)
1015588547.018.png 1015588547.019.png 1015588547.020.png 1015588547.021.png 1015588547.001.png 1015588547.002.png 1015588547.003.png 1015588547.004.png 1015588547.005.png 1015588547.006.png 1015588547.007.png
Pro ASP.NET 2.0 in VB 2005, Special Edition
Copyright © 2006 by Laurence Moroney, Matthew MacDonald (Ed.), K. Scott Allen, James Avery,
Russ Basiura, Mike Batongbacal, Marco Bellinaso, Matt Butler, Andreas Eide, Daniel Cazzulino,
Michael Clark, Richard Conway, Robert Eisenberg, Brady Gaster, James Greenwood, Kevin Hoffman,
Erik Johansson, Angelo Kastroulis, Dan Kent, Sitaraman Lakshminarayanan, Don Lee, Christopher Miller,
Matt Milner, Jan Narkiewicz, Matt Odhner, Ryan O’Keefe, Andrew Reid, Matthew Reynolds, Enrico Sabbadin,
Bill Sempf, Doug Seven, Srinivasa Sivkumar, Thiru Thangarathinam, Doug Thews
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-13: 978-1-59059-776-7
ISBN-10: 1-59059-776-1
Library of Congress Cataloging-in-Publication data is available upon request.
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
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.
Lead Editor: Ewan Buckingham
Technical Reviewer: Andy Olsen
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick,
Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft,
Jim Sumser, Keir Thomas, Matt Wade
Production Director and Project Manager: Grace Wong
Copy Edit Manager: Nicole LeClerc
Copy Editor: Kim Wimpsett
Assistant Production Director: Kari Brooks-Copony
Production Editor: Katie Stence
Compositor: Dina Quan
Artist: Kinetic Publishing Services, LLC
Proofreader: Lori Bring
Indexer: Broccoli Information Management
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com , or
visit http://www.springeronline.com .
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley,
CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com , or visit http://www.apress.com .
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 indi-
rectly by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com in the Source Code/
Download section. You will need to answer questions pertaining to this book in order to successfully
download the code.
 
1015588547.008.png 1015588547.009.png
Contents at a Glance
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxviii
About the Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
■ ■ ■ Core Concepts
PART 1
CHAPTER 1
Introducing ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CHAPTER 2
Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
CHAPTER 3
Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
CHAPTER 4
Server Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
CHAPTER 5
ASP.NET Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
CHAPTER 6
State Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
■ ■ ■ Data Access
PART 2
CHAPTER 7
ADO.NET Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
CHAPTER 8
Data Components and the DataSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
CHAPTER 9
Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
CHAPTER 10
Rich Data Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
CHAPTER 11
Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
CHAPTER 12
XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
CHAPTER 13
Files and Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
PART 3 ■ ■ ■ Building ASP.NET Websites
CHAPTER 14
User Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
CHAPTER 15
Themes and Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
CHAPTER 16
Website Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
CHAPTER 17
Resources and Localization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
CHAPTER 18
Website Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
iv
1015588547.010.png 1015588547.011.png 1015588547.012.png
PART 4 ■ ■ ■ Security
CHAPTER 19
The ASP.NET Security Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
CHAPTER 20
Forms Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
CHAPTER 21
Membership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
CHAPTER 22
Windows Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751
CHAPTER 23
Authorization and Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777
CHAPTER 24
Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803
CHAPTER 25
Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 839
CHAPTER 26
Custom Membership Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 867
PART 5 ■ ■ ■ Advanced User Interface
CHAPTER 27
Custom Server Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897
CHAPTER 28
Design-Time Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 939
CHAPTER 29
Dynamic Graphics and GDI+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 973
CHAPTER 30
Portals with WebPart Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1005
PART 6 ■ ■ ■ Web Services
CHAPTER 31
Creating Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1049
CHAPTER 32
Web Service Standards and Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . 1091
CHAPTER 33
Advanced Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1135
PART 7 ■ ■ ■ Client-Side Programming
CHAPTER 34
JavaScript and Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1173
CHAPTER 35
Atlas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1221
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1269
v
 
1015588547.013.png 1015588547.014.png
Contents
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxviii
About the Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
■ ■ ■ Core Concepts
PART 1
Introducing ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CHAPTER 1
The Evolution of Web Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
The Development World Before ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
What’s Wrong with Classic ASP? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
ASP.NET 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Seven Important Facts About ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Fact 1: ASP.NET Is Integrated with the .NET Framework . . . . . . . . . . . . . . . 7
Fact 2: ASP.NET Is Compiled, Not Interpreted . . . . . . . . . . . . . . . . . . . . . . . . 7
Fact 3: ASP.NET Is Multilanguage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Fact 4: ASP.NET Runs Inside the Common Language Runtime . . . . . . . . . 11
Fact 5: ASP.NET Is Object-Oriented . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Fact 6: ASP.NET Is Multidevice and Multibrowser . . . . . . . . . . . . . . . . . . . . 14
Fact 7: ASP.NET Is Easy to Deploy and Configure . . . . . . . . . . . . . . . . . . . . 14
ASP.NET 2.0: The Story Continues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Visual Basic 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
ASP.NET 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
CHAPTER 2
The .NET Development Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
The Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
The Visual Studio 2005 IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Websites in Visual Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Projectless Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Migrating a Visual Studio .NET Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Designing a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
vi
1015588547.015.png 1015588547.016.png 1015588547.017.png
Zgłoś jeśli naruszono regulamin