CYAN MAGENTA YELLOW BLACK PANTONE 123 C BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® Beginning ASP.NET in VB 2010 Dear Reader, Welcome aboard! Matthew MacDonald (Microsoft MVP, MCSD) THE APRESS ROADMAP Beginning ASP.NET in VB 2010 Companion eBook Pro ASP.NET in VB 2010 Pro ASP.NET MVC Framework Pro VB 2010 and the NET Platform Pro ASP.NET CMS Companion eBook Available Beginning ASP.NET in VB 2010 Matthew MacDonald, Author of Pro Silverlight in VB Pro WPF in VB 2010 Pro ASP.NET in C# 2010 ASP.NET: The Complete Reference Welcome to the most up-to-date and comprehensive beginning ASP.NET book you’ll find on any shelf As you probably already know, ASP.NET is a framework for developing modern web applications In the right hands, ASP.NET produces web applications that are secure, blisteringly fast, and highly scalable Best of all, ASP.NET includes a huge set of ready-to-use features like website navigation, data binding, themes, and user management ASP.NET allows you to create everything from a dynamic personal website to a full-scale e-commerce storefront In this book, I assume that you have only basic knowledge of VB, although those coming from a more experienced background will find that the basics are reviewed quickly and efficiently As you explore ASP.NET, you’ll learn the key database, security, and performance principles you need to know in order to design a solid web application My book will also teach you to use techniques such as object-oriented programming and code-behind development from the beginning, rather than fake it with simplified techniques that won’t work well in real life Once you’ve reached the end of the book, you will have mastered the core techniques of website programming, and you’ll have the knowledge necessary to begin work as a professional ASP.NET developer THE EXPERT’S VOICE ® IN NET Beginning ASP.NET in VB 2010 Start your journey with the fundamentals of building ASP.NET websites See last page for details on $10 eBook version www.apress.com ISBN 978-1-4302-2611-6 49 9 MacDonald SOURCE CODE ONLINE Matthew MacDonald US $49.99 Shelve in Programming Languages / Visual Basic User level: Beginner–Intermediate 781430 226116 www.it-ebooks.info this print for content only—size & color not accurate spine = 1.875" 1008 page count www.it-ebooks.info Beginning ASP.NET in VB 2010 ■■■ Matthew MacDonald www.it-ebooks.info Beginning ASP.NET in VB 2010 Copyright © 2010 by Matthew MacDonald All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright the publisher ISBN-13 (pbk): 978-1-4302-2611-6 ISBN-13 (electronic): 978-1-4302-2612-3 Printed and bound in the United States of America Trademarked names, logos, and images may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights President and Publisher: Paul Manning Lead Editor: Ewan Buckingham Technical Reviewer: Damien Foggon Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Anne Collett Copy Editor: Kim Wimpsett Compositor: Mary Sudul Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013 Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail ordersny@springer-sbm.com, or visit www.springeronline.com For information on translations, please e-mail rights@apress.com, or visit www.apress.com Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales The information in this book is distributed on an “as is” basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work www.it-ebooks.info For my wonderful family, Faria, Maya, and Brenna www.it-ebooks.info www.it-ebooks.info ■ CONTENTS Contents About the Author xxv About the Technical Reviewer xxvi Acknowledgments xxvii Introduction xxviii Part 1: Introducing NET ■ Chapter 1: The NET Framework The Evolution of Web Development HTML and HTML Forms Server-Side Programming Client-Side Programming .7 The NET Framework .9 VB, C#, and the NET Languages 11 Intermediate Language 11 The Common Language Runtime 13 The NET Class Library 14 Visual Studio .15 The Last Word 16 ■ Chapter 2: The C# Language 17 The NET Languages 17 Variables and Data Types 18 Assignment and Initializers 20 v www.it-ebooks.info ■ CONTENTS Arrays 21 Enumerations .23 Variable Operations .25 Advanced Math 26 Type Conversions 27 Object-Based Manipulation 28 The String Type 29 The DateTime and TimeSpan Types .31 The Array Type 33 Conditional Logic 35 The If End If Block 35 The Select Case Block 36 Loops .37 The For Next Block 37 The For Each Block .38 The Do Loop Block 39 Methods .40 Parameters 41 Method Overloading .41 Optional and Named Parameters 42 Delegates 43 The Last Word 45 ■ Chapter 3: Types, Objects, and Namespaces .47 The Basics of Classes 47 Shared and Instance Members 48 A Simple Class 49 Building a Basic Class 49 Creating an Object 51 Adding Properties 52 Automatic Properties 54 vi www.it-ebooks.info ■ CONTENTS Adding a Method 54 Adding a Constructor 55 Adding an Event 56 Testing the Product Class 59 Value Types and Reference Types .61 Assignment Operations 61 Equality Testing 62 Passing Parameters by Reference and by Value 62 Reviewing NET Types 63 Understanding Namespaces and Assemblies 64 Using Namespaces .66 Importing Namespaces .67 Assemblies 68 Advanced Class Programming .68 Inheritance 69 Shared Members 70 Casting Objects 71 Partial Classes 73 Generics 75 The Last Word 76 Part 2: Developing ASP.NET Applications .77 ■ Chapter 4: Visual Studio 79 The Promise of Visual Studio 79 Creating Websites 80 Creating an Empty Web Application .81 Websites and Web Projects 85 The Hidden Solution Files .86 The Solution Explorer 87 Adding Web Forms .88 vii www.it-ebooks.info ■ CONTENTS Migrating a Website from a Previous Version of Visual Studio 89 Designing a Web Page 91 Adding Web Controls 92 The Properties Window 94 The Anatomy of a Web Form 96 The Web Form Markup 96 The Page Directive 97 The Doctype 98 The Essentials of XHTML 100 Writing Code 106 The Code-Behind Class 106 Adding Event Handlers .106 Outlining .108 IntelliSense 109 Code Formatting and Coloring 114 Visual Studio Debugging 114 The Visual Studio Web Server 115 Single-Step Debugging .116 Variable Watches 121 The Last Word 122 ■ Chapter 5: Web Form Fundamentals 123 The Anatomy of an ASP.NET Application .123 ASP.NET File Types 124 ASP.NET Application Directories .125 Introducing Server Controls 126 HTML Server Controls .127 Converting an HTML Page to an ASP.NET Page 127 View State 130 The HTML Control Classes 131 viii www.it-ebooks.info ■ INDEX TextBoxStyle property, Login control, 683 TextBoxWatermarkExtender, 855 TextChanged event capturing change event immediately, 189 TextBox class, 717 web controls, 188–189 TextMode property, TextBox control class, 169 th element, HTML HTML server control class for, 132 related web control class, 169 Thawte certificate authority, 887 Theme attribute, Page directive applying themes, 377 handling control/theme conflicts, 379–380 Theme property, Page class, 383 themes App_Themes directory, 126 applying, 377–378 applying dynamically, 383 applying to entire website, 380 configuring control properties, 375 control tags in skin file, 381–382 creating multiple skins for same control, 380–381 default themes, 378 description, 359 global themes, 376 handling control/theme conflicts, 378–379 images as part of, 382–383 local, 376 skins and, 376 styles and, 359, 375 thin clients, reasons to avoid client-side programming, third-party languages and NET, 17 thread-safety, data caching, 766 three-tier design, 728–729 Throw statement , throwing exceptions, 216 throwing exceptions, 216–219 Ticket property, FormsIdentity class, 653 ticks, description, 19 time progress notification using Ajax, 837 refreshing time with partial update, 826–829 time data types, format strings, 541 timed refreshes using Ajax, 841–842 timeout attribute forms authentication settings, 643 sessionState tag, 273 Timeout property, HttpSessionState class, 266 timeout setting session state configuration, 273 Timer control, 841–842 TimeSpan class arithmetic operators, 31 nature and behavior of data types, 64 proprties and methods, 33 TimeSpan data type, NET, 19 TimeSpan type/class, 31–33 timestamps, concurrency checking, 532 Title attribute, Page directive, 389 title element, HTML, 133 Title property, 326 TitleFormat property, 314 TitleStyle property, 310 TitleText property, 684 TitleTextStyle property, 683 To Lower method, 30 To Upper( ) method, 30 Today property, DateTime class, 32 TodayDayStyle property, 310 TodaysDate property, 311, 314 ToggleButtonExtender, 855 ToList( ) method, 803, 810 Toolbox adding ASP.NET AJAX Control Toolkit, 845 stopping Toolbox hiding itself, 92 ToolTip property, WebControl class, 172 tooltips, Visual Studio, 110 TOP clause, 456 _top frame target, AdRotator control, 317 ToString( ) method DateTime class, 32 event handlers, 136 object-based manipulation, 29 TimeSpan class, 33 TotalFreeSpace property, DriveInfo class, 583 TotalSize property, DriveInfo class, 583 TotalXyz properties, TimeSpan class, 33 ToUpper( ) method, String class, 29 961 www.it-ebooks.info ■ INDEX tr element HTML, 132, 169 XHTML, 103 Trace class, 241 trace information page tracing, 234 writing trace information, 237–241 Trace object enabling page tracing, 231 Warn method, 238 Write method, 238 TraceMode attribute application-level tracing, 241 Page directive, 240 TraceMode property, Trace class, 241 tracing See page tracing TransactionCount variable, Page class, 495–497 Transfer method HttpServerUtility class, 152 Server class, 420 Transform method, XslCompiledTransform class, 633 transformations, XSLT (XSL Transformations), 632–636 TransitionDuration property, Accordion control, 849 TreeNodeDataBound event, 427 TreeNodeStyle class, 430 TreeView control applying styles to node levels, 433–434 applying styles to node types, 433 Auto Format feature, 435 binding master page to site map, 411 binding navigational controls, 415 choosing predefined set of node icons, 428 compared to Menu control, 436 description, 409 different looks for tree views, 429 ImageSet property, 428, 430 LevelStyles collection, 434 MaxDataBindDepth property, 416 NodeIndent property, 428, 430–431 NodeStyle property, 432 overview, 427 properties, 428–430 style properties, 433 styles, 431–434 table-based layouts for master pages, 400 Visible property, 401–402 TreeViewImageSet enumeration, 428 triggers controlling partial refreshes with, 832–837 Timer control, 842 Trim( ) method, String class, 29–30 TrimEnd( ) method, String class, 30 TrimStart( ) method, String class, 30 troubleshooting component-based programming, 728 Entity Framework, 802–804 Try Catch Finally blocks Catch block, 211 catching specific exceptions, 211–212 creating list of files in directory, 580 data retrieval using ADO.NET, 473 database connections, 463 Finally block, 211 nested exception handlers, 212 no active exception handler exists, 214 structured exception handling, 211 testing database connections, 467 testing occurence of exceptions, 215 tips for exception handling, 215 Using statements as alternative, 468 type attribute configuring membership provider, 669 HTML input element, 129 profile properties, 709 type conversions, 27 Type property, HtmlInputControl class, 150 TypeConverter class, 201–202 TypeName property, ObjectDataSource control, 751 types NET types, 63–64 reference types, 61–64 value types, 61–64 ■U u element, XHTML, 102, 104 ul element HTML, 169 XHTML, 102 Underline property, FontInfo class, 175 962 www.it-ebooks.info ■ INDEX underlined element, XHTML, 102 unhandled application error, 156 Unit type, 173 UnitType enumeration, 173 Universal Resource Identifiers (URIs), 626 Universal Resource Locators See URLs (Universal Resource Locators) Unload event, Page class, 192, 251, 702 Unlock( ) method, 279 UnlockUser method, MembershipUser class, 676, 679 unordered list element, XHTML, 102 Update method SqlDataSource class, 552 stateful Account class example, 739 UpdatePanel control, 832 Wizard control, 330 Update Model From Database context menu item, 798 UPDATE statement, 457–458, 475, 482 Update Wizard dialog box, 798–799 UpdateCommand property, SqlDataSource class, 519, 527–528 UpdateCommandType property, SqlDataSource class, 519 Updated/Updating events page life cycle, 517 SqlDataSource control, 527–528 UpdateFailedException class, 209 UpdateMethod property, 751 UpdateMode property, 831 UpdatePanel control browser not supporting Ajax, 826 conditional updates, 831–832 ContentTemplate element, 828 controlling refreshes with triggers, 832–837 controls that can' t be used in, 831 dynamically adding controls to, 828 error handling, 829–831 inheritance, 827 linking UpdateProgress control to, 839 refreshing label with partial update, 826–829 rendering HTML, 828 response time and bandwidth used, 829 style setting support, 827 Update method, 832 UpdateMode property, 831 updates interrupting updates, 832 updates with multiple UpdatePanel controls, 831–832 use of templates, 828 visibility of, 827 UpdatePanelAnimationExtender, 855 UpdateParameters collection, SqlDataSource class, 530, 552 UpdateProgress control AssociatedUpdatePanelID property, 839 cancel button, 839–841 linking to UpdatePanel control, 839 simulated progress bar, 837–839 UpdateProgress control, Ajax, 837–841 updates, 811–814 UpdateUser method, Membership class, 674–675, 679 updating data models, 798–799 records, data source controls, 528–532 uploading files See file uploads uploads allowing file uploads, 598–601 FileUpload control, 598 maximum size of file uploads, 601 URIs (Universal Resource Identifiers), 625 URL encoding, 261–262 UrlDecode method, HttpServerUtility class, 154, 261 UrlEncode method, HttpServerUtility class, 154, 261 urlMappings section, web.config file, 420 URLs (Universal Resource Locators) case sensitivity of in site map, 408 duplicate, site map nodes with, 407 friendly, 420 GetRedirectUrl method, 650 loopback alias, 862 mapping, 420 munged, 271 query strings transferring information in, 154, 258–262 session tracking, 265 special characters in URLs, 261 UseCookies value, HttpCookieMode enumeration, 270 UseDeviceProfile value, HttpCookieMode enumeration, 270 user authentication, Page class, 151 963 www.it-ebooks.info ■ INDEX User class, 653, 658, 697 user controls ASP.NET file type describing, 124 creating, 336–338 independent user controls, 339–341 integrated user controls, 341–343 introduction, 335 passing information with events, 346–348 requesting, 335 user control events, 344–346 web forms compared, 335 user input errors requiring validation, 285 validating input, 285 user instance connections data access, ADO.NET, 465–466 SQL Server, 465 User Instances property, connection strings, 465 user interface problems with single-value data binding, 500 three-tier design, 728 web controls, benefits of, 167 User property, Page class, 151, 652 user record management, membership data store, 661–679 User role, default Windows roles, 657 UserControl class, 335–336, 342 UserName property Login control, 682 ProfileInfo class, 719 UserNameLabelText property, 684 UsernameRequiredErrorMessage property, 684 users aspnet_Users table, 707 assigning roles using WAT, 694 authorization rules controlling access, 646–647 creating with CreateUserWizard, 686–690 creating with Membership class, 673–674 creating with WAT, 671–673 displaying full list of in web page, 720 examining user' s group membership, 656 multiple authorization rules for, 644 registering new users with Login control, 683 restricting access based on roles, 697 restricting anonymous user access, 643 using files with web applications, 573 UserType enumeration, 24 UseUri value, HttpCookieMode enumeration, 270 Using statements , closing database connections, 468–469 ■V Validate method, Page class, 294 ValidateEmptyText property, 304 ValidateUser method, Membership class, 675, 678 validation automatic validation, 287 CausesValidation property, 287 client-side validation, 287 configuring level of error checking, 113 controls BaseValidator class, 287 CompareValidator control, 286 ControlToValidate property, 288, 296 CustomValidator control, 286 description, 285 Display property, 288, 291 EnableClientScript property, 288, 294 Enabled property, 288 ErrorMessage property, 288, 295 ForeColor property, 288 hiding error messages, 288, 291 indicating invalid input to user, 292 IsValid property, 288 RangeValidator control, 286 RegularExpressionValidator control, 286, 296–300 RequiredFieldValidator control, 286 using multiple validation controls, 286 validated web form example, 300–304 validation groups, 304–306 ValidationGroup property, 304 ValidationSummary control, 286, 291–294 displaying all error messages for page, 291 964 www.it-ebooks.info ■ INDEX editing GridView templates with validation, 564–565 how validation works, 289–291 KeyPress event, 286 manual validation, 294–296 replacing custom validation with regular expressions, 303 security cookie, 643 server-side, 287 using regular expressions, 296–300 validated web forms, 300–304 validation groups, 304–306 web applications, 285 XML, 624–632 ValidationEventArgs class, 631 ValidationEventHandler event, XmlReaderSettings class, 631 ValidationGroup property, 304 ValidationSummary control, 286, 291–293 ValidationType property, XmlReaderSettings class, 630 ValidatorCalloutExtender, 855 validators See also validation, controls description, 285 validation groups, 305 ValidatorTextStyle property, 683 value attribute, HTML select element, 141 Value property HtmlInputControl class, 150 ListItem control, 178 value types assignment operations, 61 data types behaving as, 64 equality testing, 62 passing parameters by value, 62 structures, 63 value-of command element, XSL Transformations, 634 values, enumerations, 23–25 variables arrays, 21–23 block-level scope, 38 casting object variables, 71–73 data type prefixes, 20 delegate variables, 44 initialization and assignment, 20–21 operations advanced math, 26 arithmetic operators, 25 overview, 25 type conversions, 27–28 tracking variables, 121 VaryByParam attribute, OutputCache directive caching and query string, 762 caching multiple versions of web page, 764 caching with specific query string parameters, 762 VB 2010 accessibility keywords, 50 arrays, 21–23 conditional logics, 35–37 delegates, 43–45 enumerations, 23–25 loop structures, 37–39 methods, 40–45 object-based manipulation, 28–31 overview of, 17 variable initialization and assignment, 20–21 variable operations, 25–28 variables and data types, 18–25 vb files, 125 VBScript, 191 Verisign certificate authority, 887 vertical layout, 436 VerticalPadding property, TreeNodeStyle class, 431 view state EnableViewState property, Page class, 150 encryption, 247–248 example, 246–247 making secure, 247–248 retaining member variables, 249–251 retrieving values, 246 state management options, 281 state management options compared, 280–281 storing custom objects in view state, 251–252 ViewState collection, 246 web controls, 246 web farms, 882 views, multiple, 318–320 ViewState collection, 246 ViewState property, Page class, 246 965 www.it-ebooks.info ■ INDEX ViewStateEncryptionMode property, Page directive, 248 virtual directories accessing subdirectories, 870 creating, 868, 892–895 custom error pages, 880–882 description, 861 managing websites with IIS Manager, 867 removing, 869 setting default page, 879 Visible property BoundField class, 538 Control class, setting to False, 319 HtmlControl class, 148 TreeView control, 401–402 WebControl class, 172 VisibleDate property, Calendar control, 314 VisibleMonthChanged event, Calendar control, 312, 315 VisibleWhenLoggedIn property, Login control, 685 Visual Basic 2010 See VB 2010 Visual Studio adding references to components, 734, 736 applying style sheet rules, 372–373 applying themes, 377–378 automatic coloring of code, 114 automatic formatting of code, 114 Autos window, 121 benefits, 79 Breakpoints window, 120 browsing and modifying databases in, 448–450 configuring level of error checking, 113 Conversion Wizard, 90 creating components, 731 content pages based on master page, 385–388 database connection in Visual Studio, 448, 450 master page, 384–385 style sheets, 369–370 user controls, 336–338 websites, 80–90 debugging breakpoints, 116 components, 748 customizing breakpoints, 120 debugging large website, 120 overview, 114 single step debugging, 116–119 variable watch windows, 121–122 Visual Studio web server, 115–116 deploying web applications with copying website to remote web server, 895–898 creating virtual directory for new project, 892–895 overview, 892 publishing website, 898–899 description, designing web pages adding web controls, 92–94 configuring web controls in Properties window, 94 overview, 91 displaying inherited styles, 368–369 editing GridView templates in, 560–561 Error List window, 112–113 error underlining, 111–113 executing update query in, 458 generating columns with GridView control, 538–539 grid layout feature, 94 highlighted web page code, 96 IntelliSense, 25, 114 introduction, 79 Locals window, 121 member list, 109–111 migrating website from previous version, 89–90 modifying styles in Visual Studio, 366–368 multitargeting, 91 New Web Site dialog box, 81 outlining, 108–109 project files, 85 projectless development, 85 running SQL queries in, 453–454 side-by-side regions for split view, 92 Solution Explorer, 87 solution files, 86 Start Page, 80–81 tooltips, 110 tracking variables, 121 user instance dadabases, 466 966 www.it-ebooks.info ■ INDEX views of aspx page, 91 Watch window, 120 web projects, 85 writing code, 106–114 Visual Studio Help reference, 65 Visual Studio Premium, 15 Visual Studio Professional, 15 Visual Studio web server, 115 Visual StudioTest Professional, 15 Visual StudioUltimate, 15 Visual Web Developer Express, 15 VolumeLabel property, DriveInfo class, 584 ■W w \w character, 299 WAN (wide area network), 861 Warn method, 238 WAT (Website Administration Tool) creating users with, 671–673 Manage Access Rules link, 697 overview, 164–166 role-based security, 693–695 Security tab, 647, 649 setting up forms authentication using, 647–649 setting up Windows authentication using, 655 Watch window, Visual Studio, 121–122 web applications See also ASP.NET applications aspnet_Applications table, 707 benefits using files with, 574 creating with Visual Studio, 81–85 deploying additional configuration steps, 890 ASPNET/network service accounts, 872–873 code compilation, 891–892 copying website to remote web server, 895–898 creating virtual directory for new project, 892–895 publishing website, 898–899 using custom components, 890 deploying ASP.NET website, 863 file access, 573 limitations using files with, 573 problem of state for web applications, 245 representing root folder of, 405 scalability and session state, 265 security determining security requirements, 639–640 forms authentication, 641–653 Windows authentication, 655–659 tracking variables, 121 validation, 285 web.config file, 157 web browsers See also browsers Ajax and, 822–823 dealing with non-HTML in web forms, 97 web controls AdRotator control, 315–318 applying style sheet rules, 374 ASP.NET, 169–170 adaptive rendering, 167 page life cycle, 192 reasons for using, 167 workings of, 61 automatic postback, 189 AutoPostBack property, 189 Calendar control, 307–315 classes, 168–178 Color property, 174–175 configuring in Properties window, 94 default button, 177 designing web pages with Visual Studio, 92–94 enumerations, 173–174 events, 189 events and automatic postbacks, 187–192 Focus method, 177 Font property, 175–176 greeting card generator example, 195–203 HTML elements underlying, 168 HTML server controls compared, 167 inheritance, 171 list controls, 178–182 MultiView control, 320–325 prefixes, 178 properties and measurements, 173 rendering, 100 resizing, 93 rich controls, 307 967 www.it-ebooks.info ■ INDEX Download from Wow! eBook web controls (continued) server code reacting immediately to events, 188 Table control, 182–187 Unit type, 173 user control events, 344 view state, 246 visibility, 172 WebControl class, 171–173 Wizard control, 325–332 web development client-side programming, 7–9 evolution of, 3–9 HTML and HTML forms, 3–6 server-side programming, web farms, 863 Web Form controls, 307 web form designer, Visual Studio benefits, 79 web forms See also web pages creating websites with Visual Studio, 88 events, 134 validated customer form, 300–304 web hosting companies, 860, 890 web methods, 850–851 web pages absolute positioning, 94 adding web controls, 92–94 applying style sheet rules, 372–375 applying themes, 377–378 ASP.NET applications, 123 ASP.NET file type describing, 124 code structure with components, 728 complete XHTML web page, 104–105 components and structure of web form doctype, 98–100 Page directive, 97–98 web form markup, 96–97 XHTML essentials, 100–105 converting HTML page to ASP.NET page, 127–130 creating code-free web pages, 750 creating content pages based on master page, 385–388 creating master page, 384–385 creating style sheets, 369–372 creating websites with Visual Studio, 88 dealing with non-HTML in web forms, 97 default button on, 177 default content, 393–394 designing with Visual Studio, 91–94 displaying full list of users in, 720 embedding dynamic graphics, 353 focused control after rendering, 177 greeting card generator example, 195–203 grouping portions of pages, 105 indicating type of markup, 98 inheritance, 150 inserting formatted text into, 134 isolation from database, 729 master pages, 383–402 order of events in page processing, 188 page life cycle, 195 partial refreshes using Ajax, 825–837 placing custom images in, 353–355 progress notification using Ajax, 837–841 redirecting user to new page, 151–152 reference to, 172 reusing headers and footers in, 337 stacking panels in, 846 styles, 359–375 table-based layouts for master pages, 395–400 themes, 375–383 throwing exceptions without details, 748 timed refreshes using Ajax, 841–842 user controls compared, 335 web projects, Visual Studio, 85 Web Server Certificate wizard, 887 web servers allowing file uploads, 598–601 creating web server file browser, 585–588 debugging with Visual Studio, 115–116 description, 859 how web servers work, 859–860 virtual directories, 861 Visual Studio benefits, 80 Windows authentication, 655 web services, App_WebReferences directory, 126 web.config file accessing specific directories, 645 accessing specific files, 645 accessing via IIS, 164 968 www.it-ebooks.info ■ INDEX add element, 160 adjusting default membership connection string, 666 anonymousIdentification element, 721 appSettings element, 157, 160 authorization section, 697 basic structure of, 157 case-sensitivity, 157 configuration element, 157 configuration inheritance, 159 configuring with WAT, 162–164 connectionStrings element, 157 connectionStrings section, 466, 518 debugging with Visual Studio, 114 description, 125 forms authentication, 643 LocalSqlServer connection string, 705 maximum size of file uploads, 601 maxRequestLength setting, 601 multilayered configuration, 159 outputCacheProfiles section, 765 profile properties, 713 profile section, 708 role-based security, 693 serializeAs attribute, 712 session state configuration cookieless setting, 270–273 mode setting, 274–278 overview, 269 timeout setting, 273 storing custom settings in, 160–162 system.web element, 157 updating settings, 157 urlMappings section, 420 web applications, 157 Windows authentication, 655–657 XML structure of, 157 WebConfigurationManager class AppSettings property, 161 creating data-access component, 742 WebControl class, 171–173 Website Administration Tool See WAT (Website Administration Tool) website navigation ASP.NET navigation with site maps, 404 Menu control, 435–441 navigation components, 403 pages with multiple views, Wizard control, 332 site maps binding master page to site map, 410–412 binding pages to site maps, 409–410 binding portions of site maps, 412–417 defining site maps, 404–408 example site map, 408 mapping URLs, 420 nodes with duplicate URLs, 407 overview, 403 retrieving information from site maps, 417 showing subtrees, 413–416 using different site maps in same file, 416–417 SiteMap class, 417–419 SiteMapPath control, 422–427 TreeView control, 427–435 Web.sitemap file binding pages to site maps, 409 retrieving site map information from XML file, 404 showing subtrees of site maps, 414 siteMap element, 405 siteMapNode element, 405–407 using different site maps in same file, 417 websites applying theme to entire website, 380 creating with Visual Studio, 80–90 deploying ASP.NET website, 889 additional configuration steps, 890 ASPNET/network service accounts, 872–873 code compilation, 891–892 using custom components, 890 deploying ASP.NET website with Visual Studio, 892–899 copying website to remote web server, 895–898 creating virtual directory for new project, 892–895 publishing website, 898–899 managing websites with IIS Manager, 867–868 migrating from previous version of Visual Studio, 89–90 setting up website to use forms authentication, 662 Solution Explorer, 87 synchronizing remote website, 898 969 www.it-ebooks.info ■ INDEX WeekendDayStyle property, Calendar control, 310 WHERE clause, 455–456 Where clause, 790, 809 Where keyword, 812 Where property, 818 whitespace line breaks, 101 master pages, 392 regular expression characters, 299 wide area network (WAN), 861 widening conversions, 27 Width property, WebControl class, 172 wildcard character, 644 Windows account permissions, deployment configuration, 890 Windows authentication, 655–659 authorization rules, 656 Basic authentication, 884 configuring authentication in IIS 7, 886 data access, ADO.NET, 464 default Windows roles, 657 description, 641 Digest authentication, 884 examining user' s group membership, 656 IIS settings, 886 implementing Windows-based security, 655 integrated Windows authentication, 464, 884 login page, 658 modes, 884 profiles, 704 test page, 658–659 web.config settings, 655–657 WindowsBuiltInRole enumeration, 657 Windows event logs viewing Windows event logs, 220 writing to event logs, 223–224 Windows Features window, authentication in IIS 7, 885 WindowsBuiltInRole enumeration, 657 WindowsIdentity class, 653 Wizard control, 325–332 ActiveStepChanged event, 330 ActiveStepIndex property, 328 CreateUserWizard control, 687 creating wizards, 325–329 DisplaySideBar property, 325 events, 329–330 formatting the wizard, 330–332 programming models, 330 slimming down complex wizards, 329 styles, 331 styles and templates, 332 templates, 332 Update( ) method, 330 validation within wizards, 332 WizardStep controls, creating wizards, 325–329 Write method Response class, 155–156 Trace object, 238 WriteAllBytes method, File class, 592 WriteAllLines method, File class, 592 WriteAllText method, File class, 592 WriteLine method, StreamWriter class, 588 WriteStartElement( ) method, 627 WriteXml( ) method, 485 wwwroot directory creating virtual directories, 869, 892 managing websites with IIS Manager, 867 ■X x coordinate, 351 XAttribute class, 622 XCopy deployment, 890 XDocument class, 627 XDocument.Load( ) method, 621 XElement class, 622–623 XHTML attributes, 103–104 complete XHTML web page, 104–105 components and structure of web form, 100–105 configuring level of error checking, 113 documents, complete XHTML web page, 104 elements, 101–103 formatting in, 104 HTML and, 99 references to HTML in this book, 99 strict, 98 transitional, 98 970 www.it-ebooks.info ■ INDEX XML attributes creating XML document as objects, 620 syntax and values, 608 using elements or attributes, 607–608 classes XmlDocument class, 616 XmlTextReader class, 612–616 XmlTextWriter class, 609–611 comments, 162, 608 description, 99 documents class providing in-memory model of, 617 comments, 608 creating XML document as objects, 620 declaration, 607 description, 616 parsing, 605 reading, 612, 621–623 reading part of XML document, 616 searching XML document, 623 validating against schema, 632 working with XML documents in memory, 616–620 writing, 609 elements attributes, 607–608 case sensitivity, 606 composition of, 606 creating XML document as objects, 620 description, 605 empty element, 405 nesting, 606 overlapping elements, 606 special characters, 606 using elements or attributes, 607–608 whitespace, 606 formatting XML, 612 introduction, 606 metalanguage, 605 namespaces attributes, 627 namespace prefixes, 627 naming conventions, 626 xmlns attribute, 628 nodes, 612 overview, 603–604 parsers, 605 serialization, custom data types, 716 validation validating XML document against schema, 632 XML namespaces, 625–627 XSD documents, 628–632 web.config file format, 157 XML files compared to databases, 606 XSLT (XSL Transformations), 632–636 XML Schema Definition (XSD), 628–629, 632 Xml value, serializeAs attribute, 712 Xml web control, 635–636 XmlAttribute class creating XML document as objects, 620 object model for XmlDocument, 617 XmlComment class, 620 XmlDataSource class, 516 XmlDataSource control, 773 XmlDocument class GetElementById method, 623 GetElementsByTagName method, 623 in-memory model of XML documents, 617 object model, 617 overview, 616 reading XML document, 621–623 Save method, 619–620 searching XML document, 623 when to use, 623 XmlElement class, 620 XmlElement.Element( ) method, 627 xmlns attribute, 405, 626 XmlReader class, 630 XmlReaderSettings class, 630–631 XmlSchema class, 629 XmlSchemaCollection class, 629 XmlSchemaException class, 631 XmlSerializer class, 716 XmlSiteMapProvider control, 404 XmlTextReader class, 612, 614, 616, 623 XmlTextWriter class, 609–611, 627 XNamespace object, 627 xs namespace prefix, XSD documents, 629 XSD (XML Schema Definition), 624, 628–629, 632 XSL (eXtensible Stylesheet Language), 634 XslCompiledTransform class, 633, 635 XSLT (XSL Transformations), 634–637 971 www.it-ebooks.info ■ INDEX ■Y ■Z y coordinate, 351 Year property, DateTime class, 31–32 zero-based counting arrays, 21, 34 strings, 29 zero-touch deployment, 890 972 www.it-ebooks.info www.it-ebooks.info www.it-ebooks.info www.it-ebooks.info ... 49 3 Introducing Data Binding .49 3 Types of ASP. NET Data Binding 49 4 How Data Binding Works 49 4 Single-Value Data Binding 49 5 A Simple Data Binding...www.it-ebooks.info Beginning ASP. NET in VB 2010 ■■■ Matthew MacDonald www.it-ebooks.info Beginning ASP. NET in VB 2010 Copyright © 2010 by Matthew MacDonald All rights reserved... about NET programming, including Pro Silverlight in VB (Apress, 2010) and Pro WPF in VB 2010 (Apress, 2010) He’s also the coauthor of Pro ASP. NET in VB 2010 (Apress, 2010) He lives in Toronto with