Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Beginning ASP.NET 4: in C# and VB potx
Nội dung xem thử
Mô tả chi tiết
Join the discussion @ p2p.wrox.com Wrox Programmer to Programmer™
Beginning
ASP.NET 4
in C# and VB
Imar Spaanjaars
Spaanjaars
$44.99 USA
Web Development/ASP.NET $53.99 CAN
Build rich web sites with
the latest version of ASP.NET
wrox.com
Programmer
Forums
Join our Programmer to
Programmer forums to ask
and answer programming
questions about this book,
join discussions on the
hottest topics in the industry,
and connect with fellow
programmers from around
the world.
Code Downloads
Take advantage of free code
samples from this book, as
well as code samples from
hundreds of other books, all
ready to use.
Read More
Find articles, ebooks, sample
chapters, and tables of contents
for hundreds of books, and
more reference resources on
programming topics that matter
to you.
ASP.NET is the part of the .NET Framework that enables you to
build rich, dynamic web sites. The latest version—ASP.NET 4—boasts
numerous improvements to the previous iteration, including Web
Forms enhancements and jQuery support. This step-by-step book
walks you through building rich web sites with ASP.NET 4 and is
packed with in-depth examples in both C# and VB. With hands-on
exercises that take you right into the action, you’ll learn how to build web
sites firsthand while you get a good look at what goes on behind
the scenes when you view an ASP.NET 4 page in your browser.
Beginning ASP.NET 4:
• Demonstrates how to build ASP.NET 4 web pages
• Explains adding features with pre-built server controls
• Reviews working with the development tools to create ASP.NET web sites
• Shares techniques for creating consistent-looking web sites
• Teaches you how to implement jQuery and AJAX techniques in your
web sites
• Shows you how to work with databases and the Microsoft®
ADO.NET
Entity Framework
• Addresses securing and personalizing your site
• Investigates exception handling, debugging, and tracing pages
Imar Spaanjaars is a Microsoft ASP.NET MVP and runs his own company called
De Vier Koeden in the Netherlands, specializing in Internet and intranet applications
built with Microsoft technologies like ASP.NET 4. He is the author or coauthor of
several books, including ASP.NET 2.0 Instant Results and Beginning ASP.NET 3.5
in C# and VB, and is one of the top contributors to the Wrox Community
Forum at p2p.wrox.com.
Wrox Beginning guides are crafted to make learning programming languages
and technologies easier than you think, providing a structured, tutorial format
that will guide you through all the techniques involved.
Beginning ASP.NET 4
in C# and VB
Foreword by Vishal R. Joshi, Lead Program Manager, Microsoft Web Platform & Tools
Get more out of
wrox.com
Programmer to Programmer™
Interact
Take an active role online by participating in our
P2P forums @ p2p.wrox.com
Wrox Online Library
Hundreds of our books are available online
through Books24x7.com
Wrox Blox
Download short informational pieces and code
to keep you up to date and out of trouble!
Join the Community
Sign up for our free monthly newsletter at
newsletter.wrox.com
Browse
Ready for more Wrox? We have books and
e-books available on .NET, SQL Server, Java,
XML, Visual Basic, C#/ C++, and much more!
Contact Us.
We always like to get feedback from our readers. Have a book idea?
Need community support? Let us know by e-mailing [email protected]
Related Wrox Books
Beginning Visual C# 2010
ISBN: 978-0-470-50226-6
Using this book, you will first cover the fundamentals such as variables, flow control, and object-oriented programming and
gradually build your skills for Web and Windows programming, Windows forms, and data access. Step-by-step directions walk
you through processes and invite you to “Try it Out,” at every stage. By the end, you’ll be able to write useful programming code
following the steps you’ve learned in this thorough, practical book. If you’ve always wanted to master Visual C# programming, this
book is the perfect one-stop resource.
Professional ASP.NET 4: in C# and VB
ISBN: 978-0-470-50220-4
Written by three highly recognized and regarded ASP.NET experts, this book provides all-encompassing coverage on ASP.NET 4 and
offers a unique approach of featuring examples in both C# and VB, as is the incomparable coverage of core ASP.NET. After a
fast-paced refresher on essentials such as server controls, the book delves into expert coverage of all the latest capabilities of
ASP.NET 4. You’ll learn site navigation, personalization, membership, role management, security, and more.
Professional C# 4 and .NET 4
ISBN: 978-0-470-50225-9
After a quick refresher on C# basics, the author dream team moves on to provide you with details of language and
framework with C#, working in Visual Studio 2010 with C#, and more. With this book, you’ll quickly get up to date on
all the newest capabilities of C# 4.
Professional Visual Basic 2010 and .NET 4
ISBN: 978-0-470-50224-2
If you’ve already covered the basics and want to dive deep into VB and .NET topics that professional programmers use most, this
is your guide. You’ll explore all the new features of Visual Basic 2010 as well as all the essential functions that you need, including
.NET features such as LINQ to SQL, LINQ to XML, WCF, and more. Plus, you’ll examine exception handling and debugging, Visual
Studio features, and ASP.NET web programming.
Professional Visual Studio 2010
ISBN: 978-0-470-54865-3
Written by an author team of veteran programmers and developers, this book gets you quickly up to speed on what you can expect from
Visual Studio 2010. Packed with helpful examples, this comprehensive guide examines the features of Visual Studio 2010, and walks you
through every facet of the Integrated Development Environment (IDE), from common tasks and functions to its powerful tools.
Visual Basic 2010 Programmer’s Reference
ISBN: 978-0-470-49983-2
Visual Basic 2010s Programmer’s Reference is a language tutorial and a reference guide to the 2010 release of Visual Basic.
The tutorial provides basic material suitable for beginners but also includes in-depth content for more advanced developers.
Visual Studio 2010 and .NET 4 Six-in-One
ISBN: 978-0-470-49948-1
This comprehensive resource offers a single resource for all you need to know to get productive with .NET 4. It reviews all the important
features of .NET 4, including .NET charting and ASP.NET charting, ASP.NET dynamic data and jQuery, and F#. The coverage is divided
into six distinctive parts for easy navigation and offers a practical approach and complete examples.
WPF Programmer’s Reference: Windows Presentation Foundation with C# 2010 and .NET 4
ISBN: 978-0-470-47722-9
Written by a leading expert on Microsoft graphics programming, this richly illustrated book provides an introduction to WPF
development and explains fundamental WPF concepts. It is packed with helpful examples and progresses through a range of topics
that gradually increase in their complexity.
Beginning
ASP.NET 4: in C# and VB
Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
Chapter 1 Getting Started with ASP.NET 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2 Building an ASP.NET Web Site. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Chapter 3 Designing Your Web Pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
ChaPter 4 Working with ASP.NET Server Controls. . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Chapter 5 Programming Your ASP.NET Web Pages. . . . . . . . . . . . . . . . . . . . . . . . . . 139
Chapter 6 Creating Consistent Looking Web Sites. . . . . . . . . . . . . . . . . . . . . . . . . . 197
Chapter 7 Navigation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
ChaPter 8 User Controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
ChaPter 9 Validating User Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Chapter 10 ASP.NET AJAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
ChaPter 11 jQuery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
Chapter 12 Introducing Databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Chapter 13 Displaying and Updating Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Chapter 14 LINQ and the ADO.NET Entity Framework. . . . . . . . . . . . . . . . . . . . . . . . 477
Chapter 15 Working with Data — Advanced Topics. . . . . . . . . . . . . . . . . . . . . . . . . . 529
Chapter 16 Security in Your ASP.NET 4 Web Site. . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
Chapter 17 Personalizing Web Sites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
Chapter 18 Exception Handling, Debugging, and Tracing. . . . . . . . . . . . . . . . . . . . 655
Chapter 19 Deploying Your Web Site. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697
Appendix A Exercise Answers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
Appendix B Configuring SQL Server 2008. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777
502211ffirs.indd 1 2/19/10 9:58:33 AM
502211ffirs.indd 2 2/19/10 9:58:33 AM
Beginning
ASP.NET 4
502211ffirs.indd 3 2/19/10 9:58:33 AM
502211ffirs.indd 4 2/19/10 9:58:33 AM
Beginning
ASP.NET 4
in C# and VB
Imar Spaanjaars
502211ffirs.indd 5 2/19/10 9:58:34 AM
Beginning ASP.NET 4: in C# and VB
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-50221-1
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of
the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923,
(978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions
Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or
online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect
to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional
materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the
understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional
assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author
shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation
and/or a potential source of further information does not mean that the author or the publisher endorses the information the
organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet
Web sites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available
in electronic books.
Library of Congress Control Number: 2009943646
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, and Wrox Programmer to Programmer are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be
used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc.
is not associated with any product or vendor mentioned in this book.
502211ffirs.indd 6 2/19/10 9:58:34 AM
To my friends
502211ffirs.indd 7 2/19/10 9:58:34 AM
502211ffirs.indd 8 2/19/10 9:58:34 AM
About the Author
Imar Spaanjaars graduated in Leisure Management at the Leisure Management School in the
Netherlands, but he quickly changed his career path into the Internet world.
After working in the Internet business at various web agencies for the past twelve years, he recently
started up his own company called De Vier Koeden (www.devierkoeden.nl), a small Internet agency
specializing in consultancy and development of Internet and intranet applications with Microsoft
technologies such as ASP.NET 4.
Imar has written books on ASP.NET and Macromedia Dreamweaver, all published under the Wrox
brand. He is also one of the top contributors to the Wrox Community Forum at p2p.wrox.com,
where he shares his knowledge with fellow programmers.
In 2008 and 2009, Imar received Microsoft’s Most Valuable Professional (MVP) award for his
contributions to the ASP.NET community.
Imar lives in Utrecht, the Netherlands, with his girlfriend, Fleur. You can contact him through his
personal web site at http://imar.spaanjaars.com or by e-mail at [email protected].
502211ffirs.indd 9 2/19/10 9:58:34 AM
502211ffirs.indd 10 2/19/10 9:58:34 AM
Acquisitions Editor
Paul Reese
project Editor
Brian Herrmann
Technical Editor
Michael J. Apostol
Production Editor
Rebecca Anderson
Copy Editor
Kim Cofer
Editorial Director
Robyn B. Siesky
Editorial Manager
Mary Beth Wakefield
Associate Director of Marketing
David Mayhew
Production Manager
Tim Tate
Vice President and Executive Group
Publisher
Richard Swadley
Vice President and Executive Publisher
Barry Pruett
Associate Publisher
Jim Minatel
Project Coordinator, Cover
Lynsey Stanford
Compositor
Craig Johnson, Happenstance Type-O-Rama
Proofreader
Josh Chase, Word One New York
Indexer
Robert Swanson
Cover Designer
Michael E. Trent
Cover Image
© Nevin Giesbrecht/istockphoto
Credits
502211ffirs.indd 11 2/19/10 9:58:34 AM
502211ffirs.indd 12 2/19/10 9:58:34 AM
Acknowledgments
Just as with my prior books, I really enjoyed writing this one. The process from an empty Word
document at the very beginning to a printed copy as the final result is a really interesting one. Along
the way, I discovered, understood and used a lot of the new features that ASP.NET 4 and Visual
Web Developer 2010 bring. Since this book is a major update on the previous edition — Beginning
ASP.NET 3.5 in C# and VB — I have been able to incorporate a lot of reader feedback into this edition. While working on this book, I went through the more than 450 threads in the book’s forum,
looking for feedback that could improve this edition. This allowed me to add clarification and more
detailed instructions where needed. If you have the previous edition and posted a question in the
Wrox forums: thanks for your valuable feedback; you’ve really helped to make this book better.
Besides my readers, I owe a lot to other people who helped me write this book.
First of all I’d like to thank Brian Herrmann for his editorial work. Just as before, it was a pleasure
to work with you! I also want to thank Michael J. Apostol for his work as a technical editor, and the
people from Wrox for their support and contributions to this book.
Another person I owe a lot to is my friend Anne Ward from Blue Violet, a UK-based web and graphic
design company. Anne has done most of the new designs used in this book and I highly appreciate her
input. Thanks again, Anne! The concert pictures you see in this book come from Nigel D. Nudds,
who kindly let me use pictures from his collection.
Finally, I would like to thank my good friends Joost and René and my lovely girlfriend Fleur for
their support during this project.
502211ffirs.indd 13 2/19/10 9:58:34 AM