Beginning ASP.NET 4: in C# and VBISBN: 978-0-470-50221-1This introductory book offers helpful examples in a step-by-step format and has code examples written in both C# and Visual Basic.
Trang 2Beginning ASP.NET 4: in C# and VB
ISBN: 978-0-470-50221-1This introductory book offers helpful examples in a step-by-step format and has code examples written in both C# and Visual Basic With this book you will gradually build a web site example that takes you through the processes of building basic ASP.NET web pages, adding features with pre-built server controls, designing consistent pages, displaying data, and more
Beginning Microsoft Visual C# 2010
ISBN: 978-0-470-50226-6Using 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 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 C# 4 and NET 4
ISBN: 978-0-470-50225-9After a quick refresher on C# basics, the author dream team moves on to provide you with details of language and framework features including LINQ, LINQ to SQL, LINQ to XML, WCF, WPF, Workflow, and Generics Coverage also spans ASP.NET programming 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
Visual Studio 2010 and NET 4 Six-in-One
ISBN: 978-0-470-49948-1This comprehensive resource offers all you need to know to become productive with NET 4 Experienced author and NET guru Mitchel Sellers 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
Professional Visual Studio 2010
ISBN: 978-0-470-54865-3Written 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
WPF Programmer’s Reference: Windows Presentation Foundation with C# 2010 and NET 4
ISBN: 978-0-470-47722-9Written by a leading expert on Microsoft graphics programming, this richly illustrated book serves as 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
Visual Basic 2010 Programmer’s Reference
ISBN: 978-0-470-49983-2
Visual Basic 2010 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
Get more out of
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 wrox-partnerwithus@wrox.com
www.it-ebooks.info
Trang 3inTroducTion xxxix chaPTer 1 Application and Page Frameworks � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �1
chaPTer 2 ASP�NET Server Controls and Client-Side Scripts � � � � � � � � � � � � � � � � � � � � � � � � � � � � 49
chaPTer 3 ASP�NET Web Server Controls � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 85
chaPTer 4 Validation Server Controls � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 157
chaPTer 5 Working with Master Pages � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 187
chaPTer 6 Themes and Skins � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 217
chaPTer 7 Data Binding � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 237
chaPTer 8 Data Management with ADO�NET � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �309
chaPTer 9 Querying with LINQ � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 371
chaPTer 10 Working with XML and LINQ to XML � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �405
chaPTer 11 Introduction to the Provider Model � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 457
chaPTer 12 Extending the Provider Model � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 491
chaPTer 13 Site Navigation � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 519
chaPTer 14 Personalization � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �569
chaPTer 15 Membership and Role Management � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 597
chaPTer 16 Portal Frameworks and Web Parts � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �643
chaPTer 17 HTML and CSS Design with ASP�NET � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �683
chaPTer 18 ASP�NET AJAX � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 709
chaPTer 19 ASP�NET AJAX Control Toolkit � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 749
chaPTer 20 Security � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �805
chaPTer 21 State Management � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �835
chaPTer 22 Caching � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �865
chaPTer 23 Debugging and Error Handling � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �895
chaPTer 24 File I/O and Streams � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 927
chaPTer 25 User and Server Controls � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 979
chaPTer 26 Modules and Handlers � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1045
Trang 4chaPTer 29 ADO�NET Entity Framework � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1105
chaPTer 30 ASP�NET Dynamic Data � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1129
chaPTer 31 Working with Services � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1153
chaPTer 32 Building Global Applications � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �1217
chaPTer 33 Configuration � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1239
chaPTer 34 Instrumentation � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1285
chaPTer 35 Administration and Management � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1315
chaPTer 36 Packaging and Deploying ASP�NET Applications � � � � � � � � � � � � � � � � � � � � � � � � � � 1337
aPPendix a Migrating Older ASP�NET Projects � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1369
aPPendix B ASP�NET Ultimate Tools � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1381
aPPendix c Silverlight 3 and ASP�NET � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1399
aPPendix d Dynamic Types and Languages � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1419
aPPendix e ASP�NET Online Resources � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 1427
index 1429
Trang 5asP.neT 4
Trang 7asP.neT 4
in C# and VB
Bill Evjen Scott Hanselman Devin Rader
Trang 8Wiley Publishing, Inc
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
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: 2009943645
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress 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
Trang 9—Bill Evjen
To Momo and the boys Toot!
—Scott Hanselman
Trang 11Bill evjen is an active proponent of NET technologies and community-based learning initiatives for NET He has been actively involved with NET since the first bits were released in 2000 In the same year, Bill founded the St Louis NET User Group
executive director of the International NET Association (www.ineta.org), which represents more than 500,000 members worldwide
Based in St Louis, Missouri, Bill is an acclaimed author and speaker on ASP.NET and Services He has
authored or coauthored more than 20 books including Professional C# 2010, Professional VB 2008, ASP.NET Professional Secrets, XML Web Services for ASP.NET, and Web Services Enhancements: Understanding the WSE for Enterprise Applications (all published by Wiley) In addition to writing, Bill is a
speaker at numerous conferences, including DevConnections, VSLive!, and TechEd Along with these items, Bill works closely with Microsoft as a Microsoft Regional Director and an MVP
Bill is the Global Head of Platform Architecture for Thomson Reuters, Lipper, the international news and financial services company (www.thomsonreuters.com) He graduated from Western Washington University in Bellingham, Washington, with a Russian language degree When he isn’t tinkering on the computer, he can usually be found at his summer house in Toivakka, Finland You can reach Bill on Twitter
scoTT hanselman works for Microsoft as a Principal Program Manager Lead in the Server and Tools Online Group, aiming to spread the good word about developing software, most often on the Microsoft stack Before this, Scott was the Chief Architect at Corillian,
an eFinance enabler, for 6+ years, and before Corillian, he was a Principal Consultant at Microsoft Gold Partner for 7 years He was also involved in a few things like the MVP and
RD programs and will speak about computers (and other passions) whenever someone will listen to him He blogs at www.hanselman.com, podcasts at www.hanselminutes.com, and runs a team that contributes to www.asp.net, www.windowsclient.net, and www.silverlight.net
Follow Scott on Twitter @shanselman
devin rader works at Infragistics where he focuses on delivering great experiences to developers using their controls He’s done work on all of the NET platforms, but most recently has been focused on Web technologies ASP.NET and Silverlight As a co-founder
of the St Louis NET User group and a former INETA board member, and a member of the Central New Jersey NET user group, he’s an active supporter of the NET developer community He’s also co-author or technical editor of numerous books on NET, including
Wrox’s Silverlight 3 Programmer’s Reference Follow Devin on Twitter @devinrader
Trang 12carlos figueroa has been developing and designing Web solutions for the last 8 years, participating
in international projects for the pharmaceutical industry, banking, commercial air transportation, and the government During these years, Carlos has been deeply involved as an early adopter of Microsoft Web development technologies, such as ASP.NET and Silverlight
He has been awarded Microsoft Most Valuable Professional for the last 5 years and holds the MCAD certification Carlos is a Senior Software Developer at Oshyn, Inc (www.oshyn.com), a company
specialized on delivering innovative business solutions for the web, mobile devices and emerging
technology platforms At Oshyn, Carlos is dedicated to help some of the most recognizable brands in the world to achieve technology success You can reach Carlos at cfigueroa1982@hotmail.com or follow him on twitter @carlosfigueroa
andrew moore is a graduate of Purdue University–Calumet in Hammond, Indiana, and has been developing software since 1998 for radar systems, air traffic management, discrete-event simulation, and business communications applications using C, C++, C#, and Java on the Windows, UNIX, and Linux platforms Andrew is also a contributor to the Wrox Blox article series
He is currently working as a Senior Software Engineer at Interactive Intelligence, Inc., in Indianapolis, Indiana, developing server-side applications for a multimedia unified business communications platform Andrew lives in Indiana with his wife Barbara and children Sophia and Andrew
Trang 13Mary Beth Wakefield
associaTe direcTor of markeTing
Trang 15Thanks To kevin kenT, Paul reese, and jim minaTel for the opportunity to work on such a great book In addition to my co-authors, I would like to thank my family for putting up with all the writing Thank you Tuija, Sofia, Henri, and Kalle!
—Bill Evjen
Trang 17IntroductIon xxxix
Trang 18Using the Built-in Build Providers 36
chaPTer 2: asP.neT server conTrols and clienT-side scriPTs 49
Trang 19The Button server Control 91
Moving File Contents from a Stream Object to a Byte Array 137
Trang 20MultiView and View server Controls 138
Working with Controls and Properties from the Master Page 199
Trang 21nesting Master Pages 207
Trang 22Editing GridView Row Data 275
Trang 23Using Visual studio for ado.neT Tasks 344
Trang 24ReadSubtree and XmlSerialization 422
Setting Up Your Provider to Work with Microsoft SQL Server
Simpler Password Structures Through the SqlMembershipProvider 492 Stronger Password Structures Through the SqlMembershipProvider 495
Trang 25examining ProviderBase 496
Defining the Provider Instance in the web�config File 502
Not Implementing Methods and Properties of the
Implementing Methods and Properties of
Limiting Role Capabilities with a New LimitedSqlRoleProvider Provider 511
Trang 26Url Mapping 557
Working with Microsoft’s SQL Server 7�0/2000/2005/2008 588
Trang 27Examining the ProfileManager�aspx Page’s Code 594
Trang 28Building the Consumer Web Part 677
Understanding the Difficulties in Dealing with Master Pages
Trang 29chaPTer 19: asP.neT ajax conTrol ToolkiT 747
Trang 30chaPTer 20: securiTy 805
Using HttpContext.Current.items for Very short-Term storage 863
Trang 31Enabling Databases for SQL Server Cache Invalidation 883
Disabling a Database for SQL Server Cache Invalidation 885
Attaching SQL Server Cache Dependencies to the Request Object 890
Attaching SQL Server Cache Dependencies to the Cache Object 890
Trang 32debugging 910
File and Directory Properties, Attributes, and Access Control Lists 947
Trang 33Control Rendering 993
Trang 34The Controller Class and Actions 1074
Using Precompiled Business Objects in Your ASP�NET Applications 1084
Trang 35Using the entitydatasource Control 1125
Creating Your Base application with Visual studio 2010 1129
Looking at the Core Files Created in the Default Application 1130
Registering the Data Model Within the Global�asax File 1139
Invoking the Web Service from the Client Application 1164
Trang 36Adding a Service Reference 1187
Trang 37Configuring Session State 1246
Viewing Performance Counters Through an Administration Tool 1290
Writing Events via Configuration: Running the Example 1305
Trang 38chaPTer 35: adminisTraTion and managemenT 1315
Trang 39aPPendix a: migraTing older asP.neT ProjecTs 1369