While reading and using Mastering Web Development with Microsoft Visual Studio 2005, you’ll createa large-scale corporate Web site for ABC, Incorporated.. By using Server Explorer effect
Trang 2Mastering Web Development with Microsoft Visual Studio 2005
4439.book.fm Page i Wednesday, October 19, 2005 12:23 AM
Trang 34439.book.fm Page ii Wednesday, October 19, 2005 12:23 AM
Trang 4Wiley Publishing, Inc.
Web Development with
John Paul Mueller
4439.book.fm Page iii Wednesday, October 19, 2005 12:23 AM
Trang 5Acquisitions and Development Editor: Tom Cirtin
Technical Editor: Russ Mullen
Production Editor: Rachel Gunn
Copy Editor: Cheryl Hauser
Production Manager: Tim Tate
Vice President & Executive Group Publisher: Richard Swadley
Vice President and Executive Publisher: Joseph B Wikert
Vice President and Publisher: Neil Edde
Book Designer: Maureen Forys, Happenstance Type-O-Rama; Judy Fung
Compositor: Chris Gillespie, Happenstance Type-O-Rama
Proofreader: Nancy Riddiough
Indexer: Nancy Guenther
Cover Design: Design Site
Copyright © 2005 by Wiley Publishing, Inc., Indianapolis, IN
Published by Wiley Publishing, Inc., Indianapolis, IN
Published simultaneously in Canada
ISBN-13: 978-0-7821-4439-X
ISBN-10: 0-7821-4439-X
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 Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN
46256, (317) 572-3447, fax (317) 572-4355, 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 Website 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 Website may provide or recommendations it may make Further, readers should be aware that Internet Websites 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 or to obtain technical support, please contact our Customer Care Department within the U.S at (800) 762-2974, outside the U.S 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 TRADEMARKS: Sybex, Wiley, Mastering and related trade dress are trademarks of Wiley Publishing, Inc or its parent company, 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.
Screen reproductions produced with FullShot 99 FullShot 99 © 1991-1999 Inbit Incorporated All rights reserved.
FullShot is a trademark of Inbit Incorporated.
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
4439.book.fm Page iv Wednesday, October 19, 2005 12:23 AM
Trang 6This book is dedicated to my brother Mark on his 41st birthday; may all your wishes come true.
4439.book.fm Page v Wednesday, October 19, 2005 12:23 AM
Trang 7Thanks to my wife, Rebecca, for working with me to get this book completed I really don’t know what I would have done without her help in researching and compiling some of the information that appears in this book She also did a fine job of proofreading my rough draft and page proofing the result Rebecca also helps a great deal with the glossary and keeps the house running while I’m buried
in work
Russ Mullen deserves thanks for his technical edit of this book He greatly added to the accuracy and depth of the material you see here Russ is always providing me with great URLs for new prod-ucts and ideas However, it’s the testing that Russ does that helps most He’s the sanity check for my work and my code
A number of people read all or part of this book to help me refine the approach, test the coding examples, and generally provide input that every reader wishes they could have These unpaid vol-unteers helped in ways too numerous to mention here I especially appreciate the efforts of Eva Beat-tie, who read the entire book and selflessly devoted herself to this project Bill Salkin provided me with a great many ideas and URLs, as well as tested some of the examples for me A number of other readers tested procedures and helped refine the book in other ways
Finally, I would like to thank Tom Cirtin, Mae Lum, Rachel Gunn, Cheryl Hauser, and the rest
of the editorial and production staff at Sybex for their assistance in bringing this book to print It’s always nice to work with such a great group of professionals and I very much appreciate the friend-ship we’ve built over the last five books
4439.book.fm Page vi Wednesday, October 19, 2005 12:23 AM
Trang 8About the Author
John Mueller is a freelance author and technical editor He has writing in his blood, having produced
68 books and over 300 articles to date The topics range from networking to artificial intelligence and from database management to heads down programming Some of his current books include a Windows power optimization book, a book on NET security, and books on Amazon Web Services, Google Web Services, and eBay Web Services His technical editing skills have helped over 39 authors refine the content of their manuscripts John has provided technical editing services to both Data Based Advisor and Coast Compute magazines He’s also contributed articles to magazines like DevSource,
InformIT, SQL Server Professional, Visual C++ Developer, Hard Core Visual Basic, asp.netPRO, Software Test and Performance, and Visual Basic Developer He’s currently the editor of the NET electronic news-letter for Pinnacle Publishing (http://www.freeenewsletters.com/)
When John isn’t working at the computer, you can find him in his workshop He’s an avid worker and candle maker On any given afternoon, you can find him working at a lathe or putting the finishing touches on a bookcase He also likes making glycerin soap and candles, which comes in handy for gift baskets You can reach John on the Internet at JMueller@mwt.net John is also setting
wood-up a Web site at: http://www.mwt.net/~jmueller/; feel free to look and make suggestions on how
he can improve it One of his current projects is creating book FAQ sheets that should help you find the book information you need much faster
4439.book.fm Page vii Wednesday, October 19, 2005 12:23 AM
Trang 9Contents at a Glance
Introduction xxiii
Part 1 • Discovering Visual Web Developer 1
Chapter 1 • Working with Visual Web Developer 3
Chapter 2 • Creating a Simple Application 29
Chapter 3 • Using Server Explorer 59
Part 2 • Using Built-in Features 81
Chapter 4 • Working with ASP.NET 2.0 Master Pages and Themes 83
Chapter 5 • Building Intelligent Pages 115
Chapter 6 • Working with Scripts 147
Part 3 • Creating Simple but Effective Pages 189
Chapter 7 • Creating Feedback Forms 191
Chapter 8 • Developing a Site Search 219
Chapter 9 • Using Pop-ups and Redirection 255
Part 4 • Working with Dynamic Data 283
Chapter 10 • Developing Simple Database Applications 285
Chapter 11 • Using SQL Server 2005 Efficiently 315
Chapter 12 • Creating an ASP.NET Crystal Reports Web Site 359
Chapter 13 • Developing Multi-tier Applications 381 4439.book.fm Page viii Wednesday, October 19, 2005 12:23 AM
Trang 10CONTENTS AT A GLANCE ix
Part 5 • Developing Full-blown Web Applications 403
Chapter 14 • Designing Dynamic Pages with Pizzazz 405
Chapter 15 • Working with Client-side Controls 449
Chapter 16 • Creating a Shopping Cart Application 481
Part 6 • The Finishing Touches: Debug, Secure, and Distribute Your Application 523
Chapter 17 • Debugging Your Applications 525
Chapter 18 • Designing Secure Applications 545
Chapter 19 • Optimizing Your Applications 579
Chapter 20 • Creating Downloadable Applications 597
Chapter 21 • Creating Accessible Pages 629
Part 7 • Application Development Within the Corporate Environment 661
Chapter 22 • Developing Interoperable Applications 663
Chapter 23 • Using the Team Development Tools 679
Chapter 24 • Converting Visual Studio 2003 Applications 701
Chapter 25 • Moving to Visual Studio 2005 717
Appendices 735
Appendix A • A Guide to Common Development Errors 733
Appendix B • Working with Common Character Codes 745
Appendix C • 52 Indispensable Visual Studio Tricks and Techniques 753
Glossary 759
Index 789
4439.book.fm Page ix Wednesday, October 19, 2005 12:23 AM
Trang 11Introduction xxiii
Part 1 • Discovering Visual Web Developer 1
Chapter 1 • Working with Visual Web Developer 3
Introducing Visual Web Developer 3
Understanding What Visual Web Developer Provides 4
Understanding How Visual Web Developer Differs from Visual Web Developer Express Edition 6
Understanding the ASP.NET 2.0 Difference 8
Performing the Visual Web Developer Setup 10
Using the IDE 10
An Overview of the IDE Elements 11
Modifying the Visual Web Developer Options 13
Using the Design View 15
Using Source View 17
Using the Code View 18
Working with the Personal Web Site Starter Kit 21
Creating the Application 21
Working with the Application Elements 22
Modifying the Application Template to Meet Specific Needs 23
Defining the Enterprise Web Project 27
Defining Your Development Goals 27
Chapter 2 • Creating a Simple Application 29
Using the Built-in Web Server 29
Advantages of Using the Built-in Web Server 30
Disadvantages of Using the Built-in Web Server 30
Creating the Application 31
Using the Build Toolbar 34
Using the Standard Toolbar 36
Finding and Replacing Text 39
Working with the Browser Emulator 43
Understanding Save/Refresh Style Page Development 44
Performing Tasks One at a Time 44
Using the Task List Window 44
Using the HTML Source Edit Toolbar 47
Working with Control SmartTags 48
Using Internet Information Server 49
Working with Local IIS 49
Creating New Projects with IIS 50
Using the Copy Web Site Tool 52 4439.book.fm Page x Wednesday, October 19, 2005 12:23 AM
Trang 12CONTENTS xi
Designing Your Application Using Visio 53
Deciding What to Create 54
Designing a Site Map 54
Working with Existing Web Sites 56
Defining Your Development Goals 56
Chapter 3 • Using Server Explorer 59
Understanding Server Explorer 59
Creating a Server Connection 61
An Overview of Data Connections 62
An Overview of Crystal Reports Services 64
An Overview of Message Queues 64
An Overview of Services 67
Working with Event Logs 67
Using Standard Event Logs 68
Developing Custom Event Logs 70
Working with Performance Counters 71
Viewing Performance Counters 71
Creating a Simple Counter 76
Defining Your Development Goals 79
Part 2 • Using Built-in Features 81
Chapter 4 • Working with ASP.NET 2.0 Master Pages and Themes 83
Understanding Master Pages 83
Designing Master Pages 86
Creating the Master Page 86
Using Existing Resources 87
Defining the Master Page 88
Creating a Layout 89
Using the Layout Toolbar 92
Creating a Project with Master Pages 97
Creating a Content Page Using a Master Page 97
Adding a Master Page to an Existing Web Page 99
Using Multiple Master Pages in a Project 100
Understanding Themes 101
Designing Your Own Themes 102
Creating a Themes Folder 102
Defining a CSS File for a Theme 102
Defining the SKIN File and Adding Theme Resources 102
Creating a Simple Project Using Themes 104
Applying a Theme to a Page 105
Applying a Theme to a Web Site 106
Working with Cascading Style Sheets (CSS) 107
Using the Style Sheet Toolbar 107
Designing Flexible Interfaces 108 4439.book.fm Page xi Wednesday, October 19, 2005 12:23 AM
Trang 13xii CONTENTS
Creating and Using a CSS File 109
Working with CSS in the Web Page 111
Working with Microsoft Using the Web Toolbar 112
Defining Your Development Goals 113
Chapter 5 • Building Intelligent Pages 115
Understanding Server-side Intelligence 116
Detecting the Client Configuration 118
Working with Forms 123
Deciding between the GET and POST Data Handling Methods 124
Understanding the Four Levels of Data Processing 125
Processing Input Using the GET Method 125
Processing Input Using the POST Method 128
Understanding the New ASP.NET 2.0 Controls 130
Using XML Instead of HTML for Web Pages 132
Creating the XML Content 132
Interpreting the XML Using XSLT 136
Learning More about XML 139
Learning More about XSLT 140
Developing a Privacy Policy 140
Creating a Safe Environment for User Data 143
Defining Your Development Goals 145
Chapter 6 • Working with Scripts 147
Understanding Client-side Intelligence 147
Using Basic Scripting Principles 150
Creating Efficient and Effective Scripts 150
Debugging Your Scripts 151
Learning More about JavaScript 154
Working with Controls 154
Working with HTML Tags 154
Using the <Object> Tag 156
Relying on ASP.NET Controls 165
Scripting with Client Callback 167
Storing and Deleting Cookies 171
Creating and Reading Temporary Cookies 171
Creating and Reading Permanent Cookies 175
Using WebParts to Automate User Customizations 178
Adding the WebPartManager 178
Changing Selections Using a Custom Control 179
Creating Content with the WebPartZone 183
Modifying the Content with an EditorZone 184
Adding New Items with the CatalogZone 185
Viewing the Script behind the Controls 185
Keeping Data Safe with Encoding 187
Defining Your Development Goals 187 4439.book.fm Page xii Wednesday, October 19, 2005 12:23 AM
Trang 14CONTENTS xiii
Part 3 • Creating Simple but Effective Pages 189
Chapter 7 • Creating Feedback Forms 191
Understanding the Need for Feedback Forms 191
Targeting Feedback Forms to Meet Specific Needs 192
Considering What You Expect from the Form 193
Defining the Basic User Requirements 196
Using a Master Page to Create Multiple Feedback Form Types 197
Creating a User Satisfaction Form 200
Designing User Feedback 201
Developing Automated Feedback 203
Creating a Help Request Form 203
Designing the Request Page 204
Developing the XML Storage 206
Transforming the Results with XSLT 210
Developing a Beneficial Suggestion Form 213
Deciding between Required and Optional Data 214
Devising Methods of Reducing Repeat Input 215
Defining Your Development Goals 217
Chapter 8 • Developing a Site Search 219
Understanding the Site Search Types 220
Creating a Custom Site Search 220
Developing a Simple Site Search 220
Defining Preferred Links Based on Site Counters 236
Using Google to Create a Site Search 240
Using the Web Service 240
Performing a Simple SOAP Call 243
Using a Script to Call an XSLT Page 245
Translating the Result with XSLT 247
Discovering Site Maps 249
Understanding the Differences between a Site Map and a Site Search 250
Using the Site Navigation Features 250
Creating a Site Map 252
Defining Your Development Goals 254
Chapter 9 • Using Pop-ups and Redirection 255
Understanding User Concerns over Pop-ups and Redirection 256
Creating a Pop-up Form 257
Using Pop-up Forms 261
Additional Information 261
Help Pages 269
User Survey 271
Using Meta Refresh for Redirection 275 4439.book.fm Page xiii Wednesday, October 19, 2005 12:23 AM
Trang 15xiv CONTENTS
Employing Server-side Redirection 277
Understanding How Server-side Redirection Works 278
Using the Coded Method 279
Modifying the <customErrors> Element of the WEB.CONFIG File 280
Defining Your Development Goals 281
Part 4 • Working with Dynamic Data 283
Chapter 10 • Developing Simple Database Applications 285
Understanding the New SQL Server 2005 Features 286
Working with SQL Server 2005 286
Working with SQL Computer Manager 287
Using the SQL Server Management Studio 291
Using the SQLCmd Utility 299
Creating a Database Connection 305
Creating a Connection to SQL Server 305
Creating a Connection to Other DBMSs 306
Creating a Connection to Microsoft Access Using ODBC 307
Designing a Database 310
Developing a SQL Server Database Using the Wizard 311
Obtaining the Northwind and Pubs Sample Databases 311
Relying on Code-free Data Binding 313
Defining Your Development Goals 314
Chapter 11 • Using SQL Server 2005 Efficiently 315
Accessing the Database from Visual Studio 316
Using the Server Explorer 316
Creating Database Diagrams 322
Using the Table Designer Toolbar 323
Using the Data Design Toolbar 325
Using the Query Designer Toolbar 326
Creating a Blank Database 329
Adding the Database 329
Designing the Tables 331
Assigning the Relationships 333
Creating and Accessing Stored Procedures 333
Working with Stored Procedures 333
Modifying Stored Procedures 337
Creating New Stored Procedures 338
Developing Stored Procedures with NET 352
Learning More about Stored Procedures 353
Using Views 353
Using the View Designer Toolbar 354
Creating a View 354 4439.book.fm Page xiv Wednesday, October 19, 2005 12:23 AM
Trang 16CONTENTS xv
Using XML Support 354
Creating an XML Index 355
Using the XML Data Toolbar 355
Using the XML Schema Toolbar 356
Defining an XML Schema 357
Using the XML Control 357
Defining Your Development Goals 357
Chapter 12 • Creating an ASP.NET Crystal Reports Web Site 359
Creating the RPT File 359
Adding the Crystal Report 360
Selecting the Database 360
Choosing the Data 363
Working with Field Explorer 369
Formatting Report Entries 371
Setting the Report Options 373
Inserting and Removing Fields 374
Inserting and Removing Sections 376
Developing the Output Page 377
Using the CrystalReportSource Control 378
Using the CrystalReportViewer Control 378
Defining Your Development Goals 379
Chapter 13 • Developing Multi-tier Applications 381
Binding with Middle Tier Objects 381
Understanding the Middle Tier 382
Creating Direct Connections 383
Developing Web Service Connections 387
Working with Multiple Device Types 397
Understanding WAP/WML, XHTML Mobile, and cHTML 398
Using the ContentPager Control 399
Working with Emulators 401
Defining Your Development Goals 402
Part 5 • Developing Full-blown Web Applications 403
Chapter 14 • Designing Dynamic Pages with Pizzazz 405
Combining Themes, Scripts, and Other Techniques 406
Avoiding Pizzazz Overkill 406
Using Layout, Themes, and Code Behind Effectively 407
Creating Special Effects 412
Mouseover with Internet Explorer and Older Browsers 412
Mouseover with Newer Browsers 415
Presentation 416
Selection Using Scripts 420
Progressive Input Using Scripts 422 4439.book.fm Page xv Wednesday, October 19, 2005 12:23 AM
Trang 17xvi CONTENTS
Selection and Progressive Input with ASP.NET 424
Understanding the Ever Changing Browser Playing Field 425
Creating a Dynamic Presentation 426
Using the Substitution Control 426
Using the AdRotator Control 429
Working with WebParts 431
Dressing Up the WebParts 431
Using the BehaviorEditorPart Control 433
Using the DeclarativeCatalogPart and ImportCatalogPart Controls 435
Understanding How Much Customization to Provide 436
Working with Media 437
Media Uses 437
Animated GIFs 439
Audio 441
Video 442
Interactive 446
Defining Your Development Goals 447
Chapter 15 • Working with Client-side Controls 449
Understanding User Concerns about Controls 449
Creating a Control 450
Understanding the Difference between Controls and Components 451
Designing a Control 451
Designing a Component 455
Deploying a Component or Control to the Client 459
Working with the ActiveX Control Test Container 460
Creating the <Object> Tag 465
Working with the Microsoft Installer 465
Signing the MSI File 468
Registering the Component or Control 470
Setting NET Security 472
Considering the Security Issues of Using Controls 475
Using the MakeCert Utility 475
Using the Certification Authority Utility 476
Defining Your Development Goals 478
Chapter 16 • Creating a Shopping Cart Application 481
Understanding the Alternatives to a Custom Application 481
Alternative Uses of Shopping Cart Applications 482
Sidestepping the Pitfalls 483
Getting a Complete Solution 483
Obtaining Application Components 484
Developing a Merchandizing Plan 484
Creating a Web Site Layout 485
Presenting the Product 485 4439.book.fm Page xvi Wednesday, October 19, 2005 12:23 AM
Trang 18CONTENTS xvii
Developing the Product Data Flow 486
Tracking User Data 487
Getting the Payment 487
Creating the Required Databases 489
Product Listing 489
Customers 490
Orders 491
Defining Table Relationships 492
Designing Appropriate Management Applications 492
Choosing Management Tasks 493
Displaying the Data 495
Changing Pages 497
Changing Modes 498
Creating New Records 500
Updating Records 504
Deleting Records 507
Creating the Front End Pages 509
Viewing a List of Products 509
Displaying Product Specifics 512
Logging the User into the System 514
Displaying the Shopping Basket 516
Making the Sale 519
Defining Your Development Goals 522
Part 6 • The Finishing Touches: Debug, Secure, and Distribute Your Application 523
Chapter 17 • Debugging Your Applications 525
Understanding Why Debugging Is Important 525
Considering Syntax Errors 526
Considering Compile Errors 527
Considering Runtime Errors 528
Considering Semantic Errors 530
Using the Error Lookup Utility 531
Locating Hidden Errors 532
Using the Visual Web Developer 2005 Debugging Features 534
Using the Debug Toolbar 534
Using the Immediate Window 535
Using the Command Window 536
Using the Output Window 537
Using the Error List Window 539
Using the Locals Window 540
Using the Watch Window 542
Using the Call Stack Window 542
Managing Breakpoints 543
Defining Your Development Goals 544 4439.book.fm Page xvii Wednesday, October 19, 2005 12:23 AM
Trang 19xviii CONTENTS
Chapter 18 • Designing Secure Applications 545
Understanding the Common Security Issues 545
Considering the Security Issues That NET Resolves 546
Determining Where NET Can’t Help 547
Creating a Security Plan 552
Configuring ASP.NET 554
Working with the Configuration Web Site 554
Using the Login Controls 559
Checking All Incoming Data 569
An Overview of the Validators 570
Using Validators in an Application 572
Hardening Your Applications against Outside Intrusion 576
Preventing Data Leaks 576
Encrypting Your Data 577
Defining Your Development Goals 577
Chapter 19 • Optimizing Your Applications 579
Working with Performance Counters 580
Understanding Performance Counters 580
Using Standard Performance Counters 581
Using NET Specific Performance Counters 581
Creating Custom Performance Counters 583
Defining the Custom Performance Counter 584
Creating an IAsyncResult Class 589
Adding the Performance Counter to Your Application 591
Testing Your Application 591
Avoiding Performance Counter Woes 592
Analyzing Your Application 593
Using Code Analysis 593
Using the Performance Wizard 594
Defining Your Development Goals 595
Chapter 20 • Creating Downloadable Applications 597
Considering Potential Security Problems 598
Considering Client-side Setup and Configuration Issues 599
Using the Class Diagram (CD) File 601
Creating Standard Components 603
Designing the Component 603
Adding the Component to a Web Page 605
Creating Standard Controls 607
Designing the Control 607
Adding the Control to a Web Page 613
Using the FileUpload Control 616
Designing Custom SmartTags 618
Adding Standard SmartTags to a Web Page 619
Getting Pre-built SmartTags 625
Developing Downloadable Application Alternatives 626
Defining Your Development Goals 627 4439.book.fm Page xviii Wednesday, October 19, 2005 12:23 AM
Trang 20CONTENTS xix
Chapter 21 • Creating Accessible Pages 629
Reasons to Design with Accessibility in Mind 629
Making Controls Accessible 631
Adding Accessibility Attributes to Standard Controls 632
Using Alternative Attributes to Improve Accessibility 634
Using Alternative Tags to Improve Accessibility 635
Organizing the Web Page 636
Working with Forms 636
Working with Tables 639
Working with Graphics 644
Using the <NoScript> Tag 647
Testing Your Page for Accessibility Errors 652
Using the Visual Studio Built-in Checks 654
W3C HTML Validation 656
Using Bobby to Test Accessibility 657
Defining Your Development Goals 659
Part 7 • Application Development Within the Corporate Environment 661
Chapter 22 • Developing Interoperable Applications 663
Understanding the NET/Java Development Scenario 663
An Overview of the Corporate Mixed Language Environment 664
Developing Reliable Mixed Language Solutions 664
Using the Web Services Solution 666
Using the Bridging Solution 669
An Overview of JNBridge 669
Installing JNBridge 670
Creating a Bridged Application 670
Using the Cross-Compiler Solution 671
An Overview of Visual MainWin 672
Installing Visual MainWin 672
Adding IBM WebSphere Support to Visual Studio 674
Creating the Cross-Compiled Application 675
Defining Your Development Goals 677
Chapter 23 • Using the Team Development Tools 679
Understanding the Visual Studio 2005 Team Features 680
Working with Visual SourceSafe (VSS) 682
Administering VSS 682
Adding VSS to a Solution 688
Working with VSS Projects 690
Using Visual SourceSafe Explorer 695
Working with Distributed System Designers 696
Using the Application Connection Diagram 696
Using the Logical Datacenter Diagram 698
Using the System Diagram 698
Defining Your Development Goals 700 4439.book.fm Page xix Wednesday, October 19, 2005 12:23 AM
Trang 21xx CONTENTS
Chapter 24 • Converting Visual Studio 2003 Applications 701
Understanding the Process Is One Way 701
Deciding Whether You Want to Make a Change 702
Performing the Conversion 703
Understanding the Conversion Process 704
Overcoming Potential Conversion Problems 707
Considering Deprecated Features 707
Considering Difficult Conversion Issues 709
Testing the Converted Application 709
Exporting Templates 710
Creating a Project Template 711
Creating an Item Template 713
Defining Your Development Goals 716
Chapter 25 • Moving to Visual Studio 2005 717
Preserving Your Code 717
Moving the Code to IIS 718
Creating a Solution File 721
Fixing FrontPage Server Extension Problems 722
Testing Code in the New Environment 724
Compiling Your Code Using ASPNet_Compiler.EXE 724
Fixing File Association Problems 725
Using the ASPNet_RegIIS Utility 726
Using the ASPNet_RegSQL Utility 730
Defining Your Development Goals 733
Appendices 735
Appendix A • A Guide to Common Development Errors 733
Plan before You Write Code 735
Avoid Performance Bottlenecks 736
Use Page.IsPostBack to Control Resource Use 736
Perform Client-side Validation 736
Save the View State Only When Needed 737
Set the Session State 738
Use Pure HTML Whenever Possible 739
Keep Your Data Safe 739
Checking Every Input 740
Verifying Every Output 741
Work Smarter, Not Harder 741
Try the HttpServerUtility.Transfer Method 742
Use Exceptions Carefully 742 4439.book.fm Page xx Wednesday, October 19, 2005 12:23 AM
Trang 22CONTENTS xxi
Use All Available Resources 742Rely on SQL Server Stored Procedures 743Precompile the Application 743
Appendix B • Working with Common Character Codes 745
Direct Replacement Using a Chart 745Using Direct JavaScript Code 749Using Indirect JavaScript Code 749
Appendix C • 52 Indispensable Visual Studio Tricks and Techniques 753
Glossary 759 Index 789
4439.book.fm Page xxi Wednesday, October 19, 2005 12:23 AM
Trang 234439.book.fm Page xxii Wednesday, October 19, 2005 12:23 AM
Trang 24It seems like a very long time since Microsoft first announced Whidbey and eventually delivered the first beta In fact, it seems like Microsoft is taking a long time to do anything these days Some people misinterpret these long delays as a lack of enthusiasm or that perhaps the spark has just gone out of Microsoft’s development process One look at the completed Visual Studio and the many topics discussed in this book should convince you otherwise Microsoft has done one thing more than with any other previous release of Visual Studio—they’ve listened I won’t go so far as
to say that you’ll find every feature of your dreams, but Microsoft has gone a long way toward making Visual Studio the kind of product that developers will enjoy using
Mastering Web Development with Microsoft Visual Studio 2005 makes the inevitable transition easier by pointing out details of all these changes and then providing code to show you how to use them Unlike a pure ASP.NET book, you’ll also discover a wealth of techniques for combin-ing coding methods you use at the desktop with those that you now need to use on the Web site While reading and using Mastering Web Development with Microsoft Visual Studio 2005, you’ll createa large-scale corporate Web site for ABC, Incorporated In short, instead of simply dis-covering what ASP.NET provides, you’ll actually put this information into action by building a complex Web site
So What’s in Visual Studio for Me?
If you like going home on weekends and don’t like banging your head against the proverbial brick wall, Visual Studio 2005 has a lot to offer you Every developer is going to love working with master pages and themes The current development process often has developers looking for odd techniques to get repeated content onto a page Master pages make the process extremely fast and easy The ABC Incorporated Web example used in the majority of this book demonstrates the full effect of master pages on development You’ll find that the pages look very consistent, yet the book will show you that the repeated material is included only once Themes add to master pages by letting you give your Web site a consistent feel Every page uses the same colors automatically Of course, you might want to give your users a choice The ABC Incorporated Web example that runs through much of this book shows you how to do that too A simple change on the main page lets a user switch between any number of themes
You’ll find the amount of drag-and-drop functionality has increased as well For example, you’ll be amazed at how fast you can create complex pages that rely on database input using drag-and-drop techniques Mastering Web Development with Microsoft Visual Studio 2005 shows you how to improve on drag and drop using SmartTag technology Simply click an arrow next
to a control to see a SmartTag you can use to configure it This feature is especially helpful in 4439.book.fm Page xxiii Wednesday, October 19, 2005 12:23 AM
Trang 25xxiv INTRODUCTION
getting database applications put together quickly The ABC Incorporated Web site example includes a number of database examples—everything from a shopping cart to a beneficial sugges-tions Web application In fact, you’ll see just how easy it is to use XML for database purposes in this example—one of the database examples relies on XML instead of SQL Server
This book also examines new uses for some existing tools Many developers aren’t familiar with everything that Server Explorer can do Microsoft has made improvements to Server Explorer that make it a must-use tool for development You’ll find an entire chapter on this important topic By using Server Explorer effectively, you can cut the time required to create any application significantly.One of the most interesting new features in Visual Studio is WebParts Imagine providing a little extra code that lets users move items around, get rid of items they don’t want, and add items back in when they remove too much—all without bothering you That’s the beauty of WebParts You provide all of the content that anyone will need and the individual users choose what they want No longer
do you have to contend with requests for little time-consuming tweaks to your Web page design that someone else will want changed
I could go on—Visual Studio has a wealth of impressive new Web development features and you’ll find the majority of them discussed in the book One of Microsoft’s apparent, less stressed, goals was obviously to simplify things for the developer Let’s face it, most developers don’t have time any longer to fiddle with poorly implemented features Mastering Web Development with Microsoft Visual Studio 2005 helps you understand these new features and get to work quickly using all of the Visual Studio 2005 functionality
Goals for Writing this Book
One of the major goals for writing this book is to discover the real world functionality of ASP.NET 2.0 Rather than simply assume that something probably wouldn’t work or that Visual Studio had a lim-itation I couldn’t overcome, I assaulted all of the boundaries The result is this book, which discusses
a broad range of programming topics In fact, you’ll be surprised at the number of things that Visual Studio can do—I know that I was pretty amazed by the time I completed this project
Of course, testing the boundaries is nice, but you need practical examples too You’ve seen many examples designed for the corporate market in the past and frankly, at least according to the email messages I receive, most of them are so hard to understand that it’s a wonder anyone gets anything out of them at all Consequently, one of the goals for this book was to create a large-scale example that anyone can understand The ABC Incorporated example breaks all of the complex code down into easily understood parts The main menu tells you precisely where to find a particular piece of the puzzle
in the book—no guesswork involved All you need to do is play around with the example, determine what you’d like to do, and go to that part of the book It’s really that simple
Finally, this book helps you discover whether Microsoft is telling the truth about the usefulness and effectiveness of this product Is Visual Studio really a good tool for creating Web sites? After all, you have a lot of tools from which to choose I think you’ll be surprised at just how easy it is to create Web sites that not only look professional, but don’t require a lot of time to build This book demon-strates that Visual Studio can help you create Web sites of moderate size without the usual array of widgets and lost time of other products You can get to work almost immediately and use this book
as a guide while you create the masterpiece that is your Web site
4439.book.fm Page xxiv Wednesday, October 19, 2005 12:23 AM
Trang 26INTRODUCTION xxv
Who Should Read This Book?
This book isn’t for everyone I created a book for someone who wants to see what ASP.NET 2.0 and the NET Framework 2.0 provide, but who doesn’t want to spend a lot of time and effort doing it This doesn’t mean, however, that you won’t get highly developed, large-scale results: I targeted all of the examples toward the needs of an enterprise developer All of the discussion considers this audience too You won’t find a small, flimsy home network example in this book All of the applications are robust and designed to show specific Visual Studio Web development features This book even includes sections on design strategies for larger application
NOTE Don’t get the idea that I didn’t think about the small business or hobbyist developer Mybook, Mastering Microsoft Visual Web Developer 2005 Express Edition (Sybex 2006), discussesASP.NET from a small-scale development perspective
You do need to have certain knowledge to use this book I’m assuming that you’ve worked with your computer long enough to understand how it works—you won’t find any button clicking exer-cises in this book It’s also important that you know a programming language at least a little bit This book doesn’t provide basic instruction on either Visual Basic or C#; the two languages used for the examples Consequently, if you don’t know a loop from an object, you probably need to look through
a language book before getting this one, such as Mastering Visual Basic 2005 by Evangelos Petroutsos (Sybex, 2006)
Getting the Source Code
This book contains a wealth of programming examples that you’ll want to review as part of learning
to use Visual Studio You’re free to type the code in from the book, but you do have an easier means
at your disposal for getting the source code Simply go to the Sybex Web site at http://www.sybex.com/, type the last five digits of the ISBN, 4439x, in the search field, and click Go Click the link for this book and you’ll arrive at the book page Click the Download link and follow the instructions to download the source code for this book That’s all there is to it and you’ll save yourself a lot of time typing every-thing from scratch
Conventions Used in This Book
It always helps to know what the special text means in a book The following table provides a list of standard usage conventions These conventions make it easier for you to understand what a partic-ular text element means
Convention Explanation
Inline Code Some code will appear in the text of the book to help explain
application functionality The code appears in a special font that makes it easy to see This monospaced font also makes the code easier to read
4439.book.fm Page xxv Wednesday, October 19, 2005 12:23 AM
Trang 27xxvi INTRODUCTION
Convention Explanation
Inline Variable As with source code, variable source code information that
appears inline will also appear in a special font that makes them stand out from the rest of the text When you see monospaced text in an italic typeface, you can be sure it’s a variable of some type Replace this variable with a specific value The text will always provide examples of specific values that you might use
User Input Sometimes I’ll ask you to type something For example, you
might need to type a particular value into the field of a dialog box This special font helps you see what you need to type
Filename A variable name is a value that you need to replace with something
else For example, you might need to provide the name of your server as part of a command line argument Because I don’t know the name of your server, I’ll provide a variable name instead The variable name you’ll see usually provides a clue as to what kind of information you need to supply In this case, you’ll need to provide
a filename Although the book doesn’t provide examples of every variable that you might encounter, it does provide enough so that you know how to use them with a particular command
[Filename] When you see square brackets around a value, switch, or
command, it means that this is an optional component You don’t have to include it as part of the command line or dialog field unless you want the additional functionality that the value, switch, or command provides
File Open Menus and the selections on them appear with a special menu
arrow symbol “File Open” means “Access the File menu and choose Open.”
italic You’ll normally see words in italic if they have special meaning
or if this is the first use of the term and the text provides a definition for it Always pay special attention to words in italic because they’re unique in some way When you see a term that you don’t understand, make sure you check the glossary for the meaning of the term as well The glossary also includes definitions for every acronym in the book
monospace Some words appear in a monospace font because they’re easier
to see or require emphasis of some type For example, all filenames in the book appear in a monospace font to make them easier to read
URLs URLs will normally appear in a monospace font so that you
can see them with greater ease The URLs in this book provide sources of additional information designed to make your development experience better URLs often provide sources
of interesting information as well
4439.book.fm Page xxvi Wednesday, October 19, 2005 12:23 AM
Trang 28Part 1
Discovering Visual Web Developer
In this part:
◆ Chapter 2: Creating a Simple Application
◆ Chapter 3: Using Server Explorer
4439.book.fm Page 1 Monday, October 17, 2005 9:12 PM
Trang 294439.book.fm Page 2 Monday, October 17, 2005 9:12 PM
Trang 30Chapter 1
Working with Visual Web Developer
When you installed Visual Studio NET 2005, you might have been surprised to find a bonus—Visual Web Developer This new product fills a gap in the Visual Studio product line and is Microsoft’s rec-ognition that Web development has become a major part of the application market In many respects, Visual Web Developer is simply a combination of older technologies such as FrontPage, mixed with the Visual Studio projects, and all of the new features found in ASP.NET 2.0 However, it’s more than just the combination of those features, as you’ll see in this chapter and as the book progresses Visual Web Developer is a full-fledged development environment capable of creating enterprise-level appli-cations of any complexity
The focus of this chapter is introducing you to the Visual Web Developer environment, which means discussing ASP.NET 2.0 to an extent, discussing installation requirements, and looking at the IDE However, you really won’t get to know Visual Web Developer until you work through a project
or two Consequently, the chapter also delves into the sample application project that comes with Visual Web Developer—a personal Web site It’s not a big project nor is it something that you’re likely
to use as an enterprise developer, but it does provide a great view of Visual Web Developer features and that’s how this chapter uses it
This book does consider enterprise-programming needs Instead of working with a number of individual projects, this book discusses several major projects that demonstrate the complex envi-ronment that many enterprise developers encounter every day The final section of this chapter describes the enterprise project presented in this book When you’re done with this project, you’ll have a resource you can use for reference in your own projects and some source code that you can borrow as well
Introducing Visual Web Developer
Microsoft designed Visual Web Developer to provide complete Web development support This new product is a combination of development products that Microsoft introduced in the past, along with some new ideas that make Visual Web Developer unique Don’t confuse this product with another version of Visual InterDev or Web Matrix It’s more a combination of the features provided with pre-vious versions of Visual Studio and FrontPage, along with new functionality that only ASP.NET 2.0 provides, including new technologies such as WebParts (You can find WebParts described in detail
in several places in this book, starting with the “Using WebParts to Automate User Customizations” section of Chapter 6.)
4439.book.fm Page 3 Monday, October 17, 2005 9:12 PM
Trang 314 CHAPTER 1 WORKING WITH VISUAL WEB DEVELOPER
Understanding What Visual Web Developer Provides
You can create Web applications and Web services using C#, Visual Basic, and Visual J# This book concentrates on providing examples in C# and Visual Basic The idea is that Visual Web Developer is
a separate environment for creating Web resources It even includes a special project that generates a fully functional personal Web site that you can use for experimentation The “Working with the Per-sonal Web Site Starter Kit” section discusses many of the elements of this sample application and helps you understand how to use it to your benefit
Fortunately, you don’t have to rely only on special technologies to use Visual Web Developer You can create standard Web pages as well, using common tags and scripts Chapter 6 shows how you can perform this type of development The idea is that sometimes simple is better when it comes to certain page types For example, you might find yourself using some of these techniques to ensure a page remains accessible, as described in Chapter 21
One of the best features of Visual Web Developer is that you can move any Web application you create from your local drive to the server using the Copy Web tool shown in Figure 1.1 For those familiar with FrontPage 2003 (see Figure 1.2), this feature looks very familiar The two products use
a similar—but not precisely the same—interface for remote connectivity Microsoft has focused on using FrontPage technology and then improving it in Visual Web Developer You can learn more about this feature in the “Using the Copy Web Site Tool” section of Chapter 2
The reason that the FrontPage 2003 connection is so important is that Microsoft did borrow some ideas from FrontPage for Visual Web Developer For example, the concept of master pages started with FrontPage, but you’ll see them developed more fully in Visual Web Developer as Microsoft stretches the technology to meet new needs You’ll first encounter master pages and themes in Chap-ter 4 of the book These interface elements make Visual Web Developer easier to use and are consis-tent with Microsoft’s goal for this product of creating a great programming environment for businesses of any size FrontPage includes functionality that emphasizes simplicity over a heavy-duty programming environment
Figure 1.1
Use Visual Web Developer
to interact with both
local and remote sites
4439.book.fm Page 4 Monday, October 17, 2005 9:12 PM
Trang 32INTRODUCING VISUAL WEB DEVELOPER 5
Visual Web Developer also supports many features that reduce programming complexity For example, you have full access to the SmartTags that appear with many Microsoft products today SmartTags reduce complexity by limiting the amount of custom code you must create At the same time, the user gains full access to the functionality a SmartTag can provide For example, when a Web page contains a stock symbol, a special SmartTag provides information about the stock symbol, such
as the number of shares traded SmartTags also affect the development environment, as shown in ure 1.3 This SmartTag helps you configure a FormView control You’ll discover more about using SmartTags in the “Working with Control SmartTags” section of Chapter 2 You’ll see how to add your own SmartTags to Web pages in the “Designing Custom SmartTags” section of Chapter 20
Fig-Most developers will also appreciate the save/refresh style of working with Web pages that Visual Web Developer provides In the past, you often had to close the browser, make any required changes
to your code, and reopen the browser to see the effects In a worst-case scenario, you might have to restart Internet Information Server (IIS) to see the change With Visual Web Developer, all you need
to do is make the change, save and compile the code in the IDE, and then click Refresh on the browser to see the change The “Understanding Save/Refresh Style Page Development” section of Chapter 2 describes this technique in detail
Figure 1.2
Visual Web Developer
borrows some ideas from
FrontPage 2003
Figure 1.3
Using SmartTags
reduces end user
inter-face and other
develop-ment complexity
4439.book.fm Page 5 Monday, October 17, 2005 9:12 PM
Trang 336 CHAPTER 1 WORKING WITH VISUAL WEB DEVELOPER
Developers have complained that using the debugger for Web pages in previous versions of Visual Studio NET was difficult In fact, Microsoft has an entire range of Knowledge Base (http://support.microsoft.com/default.aspx?scid=fh;EN-US;KBHOWTO) articles designed to make this process easier, but sometimes the solutions don’t work as expected Because debugging Web pages
is difficult, the inclusion of a complete debugger optimized for Web development is important from
a productivity perspective Visual Web Developer includes such a debugger Chapter 16 tells you more about debugging your applications
Understanding How Visual Web Developer Differs from Visual Web Developer Express Edition
You might have seen the Visual Web Developer Express Edition offering on Microsoft’s Express product Web site at http://lab.msdn.microsoft.com/express/ and thought that Microsoft might
be offering the full product free Besides the fact that Microsoft didn’t integrate Visual Web Developer Express Edition with the rest of the Express product line, it also lacks a number of important features for the enterprise developer Consequently, although you can use the Express products to experiment and to learn about new NET Framework features, it isn’t the correct environment in which to build full-fledged applications of any size In fact, the full version of Visual Web Developer found in Visual Studio NET offers these features—all of which appear throughout the book as part of the enterprise application described in the “Defining the Enterprise Web Project” section of the chapter
Server Explorer This feature lets the developer interact with the majority of the server ality directly It includes support for performance counters, event log, message queues, services, and any installed copies of SQL Server Server Explorer can also provide access to special features when installed For example, when you install Crystal Reports, you can access any Crystal Services features from Server Explorer Other vendors can provide similar access for server-level features Chapter 3 helps you understand Server Explorer better
function-Team Support Team development is extremely important Without team development support, developers can overwrite each other’s code and it’s impossible to manage a project Visual Web Developer 2005 provides full team development support through an updated version of Visual Source Safe It also includes a new tool called Visual Studio Team System You can also add team development support using third party packages Chapter 23 helps you understand the team devel-opment support in Visual Web Developer better
Crystal Reports Building a report by hand is time consuming with NET because you have to construct the report as a graphic image A better solution is to rely on a third party offering such
as Crystal Reports The Crystal Reports designer lets you create a report graphically and let the Crystal Reports engine determine how to get the report onto paper Even though Visual Web Developer doesn’t include the full Crystal Reports product, it includes enough functionality to cre-ate basic reports without any problem You can see an overview of Crystal Reports functionality
in the “An overview of Crystal Reports Services” section of Chapter 3 An example of using Crystal Reports in an application appears in Chapter 12
Additional Controls Visual Web Developer includes a number of controls not found in the Express product For example, it includes a ConnectionsZone Web part that makes creating connections a lot easier All of the additional controls relate to some type of enterprise-level func-tionality You can find WebParts specific discussions in the “Using WebParts to Automate User Customizations” section of Chapter 6 and the “Working with WebParts” section of Chapter 14.4439.book.fm Page 6 Monday, October 17, 2005 9:12 PM
Trang 34INTRODUCING VISUAL WEB DEVELOPER 7
Additional Projects Visual Web Developer includes the full set of projects that come with Visual Studio NET The projects include a number of control, component, and Web site projects that don’t appear in the Express product You’ll see these projects in use throughout the book
Additional Development Windows Visual Web Developer includes a number of additional development windows Some of these windows are related to debugging features—such as the inclusion of additional watch and local windows The most important window is the browser emulator It lets a developer test various browser environments with the application to see how the application will appear to the user The various windows appear in different sections of the book You can find the common windows described in the “An Overview of the IDE Elements” section
of this chapter The browser emulator appears in the “Working with the Browser Emulator” tion of Chapter 2 All of the debugging information appears in Chapter 17
sec-Design Tools Microsoft is placing increased emphasis on application design Visual Web oper includes a copy of Visio for creating an application design Even though it isn’t the best tool,
Devel-it does work well enough to create fairly complex designs wDevel-ith lDevel-ittle trouble You’ll find a brief overview of Visio in the “Designing Your Application Using Visio” section of Chapter 2 The developer also has access to several built-in controls including Class Diagram (Chapter 21), Appli-cation Connection Diagram (Chapter 23), System Diagram (Chapter 23), and Logical Datacenter Diagram (Chapter 23)
Optimization Tools Creating an optimized application environment is especially important for commercial Web sites Not only does Visual Web Developer provide access to performance counters and specialized optimization controls (Chapters 3 and 19), but it also provides support for Analysis Server, which allows a developer to profile an application and locate problem areas quickly You’ll find a complete discussion of Analysis server in the “Using Analysis Server Counters” and “Using Analysis Server” sections of Chapter 19 Other profiling and optimization tools appear throughout the book Of course, you’ll also find the add-on servers that Microsoft has provided with every other version of Visual Studio NET
Development Tools The developer will have full access to all of the Visual Studio NET opment tools including ActiveX Control Test Container, Create GUID, Error Lookup, ATL/MFC Trace Tool, OLE/COM Object Viewer, and Spy++ You’ll find these tools discussed throughout the book For example, you’ll find the ActiveX Control Test Container described in the “Working with the ActiveX Control Test Container” section of Chapter 15 The Error Lookup utility appears
devel-in the “Usdevel-ing the Error Lookup Utility” section of Chapter 17
Additional Configuration Options Many of the additional configuration options relate to cial project capabilities that Visual Web Developer provides that don’t appear in Visual Web Developer Express For example, the developer will find settings that modify how the keyboard reacts when accessing either Word 2003 or Excel 2003 from within the Visual Studio IDE A special Device Tools folder contains all of the settings for working with emulators for applications on other devices, such as cellular telephones and the Pocket PC The “Modifying the Visual Web Developer Options” section of the chapter discusses configuration option access in detail
spe-Full Version of MSDN Even though a developer can use the online version of Microsoft oper Network (MSDN), it’s a pain Having the full version of MSDN available right at your desk-top makes working with this important resource fast In addition, it’s possible to customize the local copy of MSDN with notes and to flag local MSDN pages You can’t easily do this with the online version
Devel-4439.book.fm Page 7 Monday, October 17, 2005 9:12 PM
Trang 358 CHAPTER 1 WORKING WITH VISUAL WEB DEVELOPER
Understanding the ASP.NET 2.0 Difference
One of the essential new features for NET is the introduction of ASP.NET 2.0 The features included with ASP.NET determine what you can do with Web pages and how these pages appear to the end user The latest version of ASP.NET also promises better performance and security, which is good news for enterprise developers who have often complained about too little of both in ASP.NET Of course, only time will tell just how well Microsoft integrated these new features into the old product and whether those old security holes are really gone
The move from older versions of ASP.NET might not be as seamless as you’d like Enterprise developers will probably want to target new ASP.NET applications first, and then think about mov-ing older applications As Microsoft begins to overcome security, reliability, and performance issues with Windows and other products, ASP.NET has to change as well One of the better places to obtain the insights of developers that have made the move is the ASP.NET 2.0 and Visual Studio 2005 Tips and Tricks forum at http://forums.asp.net/134/ShowForum.aspx
Enterprise developers have learned the hard way that previous versions of ASP.NET could deliver
a good partial solution, but a full solution often required jumping through hoops and using fancy code fixes The repetitive code required for these tricks was hard to manage and it could be inconve-nient to apply the fixes ASP.NET 2.0 fixes many of the fit-and-finish problems by adding features to existing controls In addition, Microsoft has improved the convenience factor for developers by incor-porating a new concept borrowed from FrontPage 2003—master pages and themes
A master page lets you create a Web page that contains elements that all or a group of Web pages must have and then use that page as a means of starting all of the pages on a Web site A theme con-tains graphical and structural elements that define a basic concept for your Web site, such as using red for all title text Figure 1.4 shows a typical example of a master page (note that it has a MASTER file extension) You’ll learn more about working with master pages and themes in Chapter 4
Figure 1.4
Master pages give a Web
site a consistent look and
greatly reduce
develop-ment time
4439.book.fm Page 8 Monday, October 17, 2005 9:12 PM
Trang 36UNDERSTANDING THE ASP.NET 2.0 DIFFERENCE 9
You’ll also find many new developer productivity features in ASP.NET 2.0 For example, Microsoft has made it easier to add security to your Web application ASP.NET 2.0 includes both credential stor-age and role management support without adding a lot of additional code Chapter 18 tells you more about creating secure applications using Visual Web Developer Personalization services (discussed
in Chapter 14) make it easier to store user information so that every user has a custom experience The use of site navigation to provide better access to Web pages and site counters to measure performance ensure that you can manage a site with greater ease Both features appear in the “Creating a Custom Site Search” section of Chapter 8
Part of the personalization functionality comes with a new technology called WebParts This nology includes a number of controls that let the user change the content, appearance, and behavior
tech-of a Web page directly from a browser You can use this technology to ensure that a Web page meets specific user needs such as accessibility or to allow the user to view content in another way (see the
“Using WebParts to Automate User Customizations” section of Chapter 6)
NOTE ASP.NET 2.0 supports 64-bit computing Generally, working with a 64-bit application in.NET isn’t any different from working with a 32-bit application from a coding perspective However,you’ll need to change the project settings and recompile the application
ASP.NET 2.0 comes with 45 new controls that make creating applications a lot easier Many of these controls are encapsulations of features developers requested and many had to be created by hand previously You’ll find examples of these new controls in many places in the book However, the new controls are so important that you’ll find many of them described in the “Working with Forms” section of Chapter 5 These controls also support multiple device types now so you don’t have to do anything special to serve up a Web page to someone with a handheld device The “Working with Multiple Device Types” section of Chapter 13 describes this feature in detail
Management is a big issue because the Webmaster or network administrator usually performs the task, rather than the developer who created the application Microsoft has made management easier
by better documenting the WEB.CONFIG and MACHINE.CONFIG files In addition, you’ll find scripts for managing these files as part of the ASP.NET 2.0 installation You can find out more about these fea-tures in the “Employing Server Side Redirection” section of Chapter 9
There are a number of places online to learn more about ASP.NET 2.0 Of course, you’ll discover
a lot more about ASP.NET 2.0 functionality as this book progresses Beginning with Chapter 7, the examples in the book demonstrate various ASP.NET 2.0 features that you get with Visual Web Devel-oper For example, the “Targeting Feedback Forms to Meet Specific Needs” section of Chapter 7 describes how you can use a master page to develop multiple feedback form types so that ad hoc sur-veys are much easier to implement Besides the resources in the book, however, you might also want
to obtain Introducing ASP.NET 2.0 by Dino Esposito (Microsoft Press, 2004), and view these Web sites
Basic ASP.NET 2.0 Overview http://www.asp.net/whidbey/whitepapers/
AspNetOverview.aspx
MSDN ASP.NET 2.0 Topics http://msdn.microsoft.com/asp.net/default.aspx
ASP.NET Security Article http://www.sitepoint.com/article/asp-net-2-security
Master Pages in ASP.NET 2.0 http://www.c-sharpcorner.com/Code/2004/May/
MasterPages.asp
New Features of ASP.NET 2.0 http://www.c-sharpcorner.com/Code/2004/July/
NewFeaturesASPNET.asp4439.book.fm Page 9 Monday, October 17, 2005 9:12 PM
Trang 3710 CHAPTER 1 WORKING WITH VISUAL WEB DEVELOPER
Performing the Visual Web Developer Setup
Now that you’ve seen what Visual Web Developer can do for you as a developer, you might be dering how you can get a copy of this amazing product for your own You might already have it installed on your machine When you choose a default setup for any Visual Studio NET 2005 lan-guage product, you also get Visual Web Developer The only time you won’t get Visual Web Devel-oper is when you choose a custom setup and specifically clear the Visual Web Developer selection in the Language Tools folder of the Setup application
won-Theoretically, you can install Visual Web Developer as a stand-alone product In reality, you’ll want to combine it with another language product such as Visual Basic or C# so that you can create components and perform other tasks that Visual Web Developer can’t perform because it lacks that desktop environment projects This book assumes that your setup includes Visual Web Developer and another language product in order to create a complete development environment
Microsoft provides a basic set of requirements for Visual Web Developer, but these assumptions aren’t very realistic for the enterprise developer Table 1.1 provides a more realistic set of require-ments that depend on the kind of applications you want to create When you want to create a small Web site for the LAN, you can get by with the Simple Setup options Most developers require the Average Setup options Any developer performing extensive database management tasks or working with large applications will want system that meets the Complex Setup options
It’s important to remember that Visual Studio NET requires a minimum of 600 MB to install, you need a minimum of 566 MB extra for MSDN, and the NET Framework requires 264 MB of drive space
In short, you need to consider all of your needs before you begin the installation At one time, ers considered a 30 GB drive huge; it might not seem so large with the requirements of this latest version
develop-of Visual Studio, especially if you also have SQL Server 2005 installed on the same system
Using the IDE
The focus of development language products today is the IDE because the IDE determines how fast and defines how well a developer can write the application The IDE includes the actual development interface, provides access to components and controls, lets the developer debug the application, and includes the projects and wizards used to create both applications and application elements You’ll
Requirement Simple Setup Average Setup Complex Setup
4439.book.fm Page 10 Monday, October 17, 2005 9:12 PM
Trang 38USING THE IDE 11
find the code used to explore the various view in the \Chapter 01\Views folder of the source code
on the Sybex Web site
NOTE You could write a NET Framework application using nothing more than a text editor such asNotepad The ILASM.EXE file in the \WINDOWS\Microsoft.NET\Framework\v2.0.50215folder will compile the information you provide into a NET application However, working with.NET this way would be one of the most time-consuming and error-prone ways of creating an appli-cation imaginable In short, don’t get the idea that the IDE provides the language features—it pro-vides the capability to work with the language in an efficient manner The NET Frameworkprovides the language features
An Overview of the IDE Elements
When you first open Visual Web Developer, you’ll see what seems like a confusing array of panes in
a main window, as shown in Figure 1.5 However, far from being a confusing array of panes, each one
of these client windows is actually a part of the development environment Figure 1.5 provides a label for each one of the major windows that Visual Web Developer opens If you don’t see one or more of these windows, you can always open it by using the options on the View menu For example, to open the Solution Explorer window, select View Solution Explorer
Each of these windows has a special purpose in helping you create applications faster The ing list provides an overview of each of the windows and tells how you’d use the window You’ll obtain additional information about the windows as the book progresses
follow-Standard Toolbar The Standard toolbar contains common buttons that let you create a new project; add items to a project; save a single or multiple files; cut, copy, or paste items; undo or redo actions; start an application; or find information in the project files These tasks are common to most file types, so Visual Web Developer normally displays the Standard toolbar
Figure 1.5
The Visual Web Developer
IDE provides a number of
features for creating
ap-plications quickly
4439.book.fm Page 11 Monday, October 17, 2005 9:12 PM
Trang 3912 CHAPTER 1 WORKING WITH VISUAL WEB DEVELOPER
Formatting Toolbar The Formatting toolbar lets you perform a range of text and object uration tasks For example, you can choose the style used to display text on screen (a style defines how similar text should look) You can also augment existing text by modifying the font, font size, and attributes Any object can receive a foreground or background color change You use the jus-tification options on paragraphs to determine the text alignment Individual text elements can also include bullets or numbers Finally, you can convert an URL into a hyperlink that the user clicks
config-to go config-to a different Web page or download a resource
Other Toolbars Not shown in Figure 1.5 is the wealth of other toolbars For example, the Build toolbar contains options that help you compile the application These toolbars appear in other sec-tions of the book
Solution Explorer Solution Explorer is a kind of outline of your entire project It shows which files and references your project includes You can also use Solution Explorer to access the project settings and add new items Finally, Solution Explorer can help you organize your project to make
it easier to work with
Class View The Class View contains an outline of your project from an Object Oriented gramming (OOP) perspective You can see the classes your application contains Within the classes, you’ll find the methods, events, and properties that your application contains The Class View contains information about the visibility of application elements and helps you understand the organization of your application better
Pro-Properties Window The Properties window contains three elements At the top, you see the selected item You can select a new item from the drop-down list The middle of the Properties window contains the properties for the selected item Every item contains unique properties based
on its object type The bottom of the Properties window contains an explanation of the selected property when an explanation is available
Editing/Design Area This is the place where you actually edit or design a Web page The content changes to reflect the currently selected window tab For example, when working with a HyperText Markup Language (HTML) document, you’ll see tabs for a Source view and a Design view The Design view lets you modify the graphic elements of the Web page, while the Source view lets you change the code used to create the graphic elements One or more tabs at the top of the editing/design area let you choose the file you want to work with when multiple files are open Figure 1.5 shows the Design window (view)—this book examines many other views that Visual Web Devel-oper provides
Source Window Tab Selecting the Source tab displays the Source window where you edit code used to create an application The Source window lets you edit multiple languages—everything from C# and Visual Basic NET to HTML and eXtensible Markup Language (XML) The Source window can even appear when there isn’t any design to perform In some cases, you’ll create data files using the Source window that provides input to your application In sum, the Source window
is the most common window that you’ll see when using Visual Web Developer
Design Window Tab Whenever a file offers a visual element—something the user can act with—you’ll see the Design tab—selecting this tab displays the Design window shown in Figure 1.5 In this case, the display is showing a standard Active Server Pages eXtended (ASPX) file, the kind that you work with most often
inter-4439.book.fm Page 12 Monday, October 17, 2005 9:12 PM
Trang 40USING THE IDE 13
Server Explorer Tab Server Explorer is one of the most important, yet least used, features of Visual Studio NET Many developers haven’t transitioned to using this tool very well and still code application elements by hand Using this one tool, you can drag and drop everything from performance counters to event log elements onto your project The elements contain all of the basic configuration information, so all you need to do is provide custom settings You also use Server Explorer to access databases and to create reports It’s easy to create connections to any server that you can access on the network, making this tool an easy means of exploring the network without leaving the IDE Chapter 3 discusses Server Explorer in detail
Toolbox Tab The Toolbox tab selects the Toolbox—a container filled with controls that you use to create the visual elements of an application Every control has a different purpose and the applications in this book show you how to use many of them The “Understanding the New ASP.NET 2.0 Controls” section of Chapter 5 also highlights many of the interesting controls in the Toolbox
TIP You can click the AutoHide button (the one that looks like a thumbtack) in the upper right corner
of any window to hide that window The window remains accessible—all you need to do is move thecursor over its tab, but the IDE hides the window when you don’t need it To display a window again,simply click the AutoHide button again The position of the thumbtack on the AutoHide button tellsyou whether the IDE will hide the window The IDE always displays the window when the thumb-tack points straight down
Modifying the Visual Web Developer Options
When you first start Visual Web Developer, you’ll want to change the IDE options to meet your sonal needs You’ll also want to check the settings every time you begin a new project to ensure that the settings meet project needs To modify the Visual Web Developer settings, select the Tools Options command and you’ll see the Options dialog box shown in Figure 1.6 (The figure shows all
per-of the options expanded—these options aren’t visible when you initially open the dialog box.)
Figure 1.6
The Options dialog box
contains the Visual Web
Developer Settings
4439.book.fm Page 13 Monday, October 17, 2005 9:12 PM