1. Trang chủ
  2. » Công Nghệ Thông Tin

Beginning ASP.NET 4 in C# 2010 ppsx

1K 1,4K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.017
Dung lượng 21,6 MB

Nội dung

this print for content only—size & color not accurate spine = 1.90625" 1016 page count MacDonald ASP.NET 4 in C# 2010 THE EXPERT’S VOICE ® IN .NET Beginning ASP.NET 4 in C# 2010 CYAN MAGENTA YELLOW BLACK PANTONE 123 C Matthew MacDonald Companion eBook Available Start your journey with the fundamentals of building ASP.NET websites BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® Beginning ASP.NET 4 in C# 2010 Dear Reader, 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 naviga- tion, data binding, themes, and user management. ASP.NET allows you to cre- ate 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 C#, 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. Welcome aboard! Matthew MacDonald (Microsoft MVP, MCSD) Matthew MacDonald, Author of Pro ASP.NET 4 in C# 2010 Pro Silverlight 4 in C# Pro WPF in C# 2010 ASP.NET: The Complete Reference US $49.99 Shelve in: Programming Languages / C# User level: Beginning–Intermediate THE APRESS ROADMAP Pro ASP.NET 4 CMS Pro ASP.NET MVC 2 Framework Pro ASP.NET 4 in C# 2010 Pro C# 2010 and the .NET 4 Platform Beginning ASP.NET 4 in C# 2010 www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN 978-1-4302-2608-6 9 781430 226086 5 49 9 9 Beginning Beginning ASP.NET 4 in C# 2010 ■ ■ ■ Matthew MacDonald Beginning ASP.NET in C# 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-2608-6 ISBN-13 (electronic): 978-1-4302-2609-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 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 orders- ny@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. For my wonderful family, Faria, Maya, and Brenna ■ CONTENTS v Contents About the Author xxv About the Technical Reviewer xxvi Acknowledgments xxvii Introduction xxviii Part 1: Introducing .NET 1 ■ Chapter 1: The .NET Framework 3 The Evolution of Web Development 3 HTML and HTML Forms 3 Server-Side Programming 6 Client-Side Programming 7 The .NET Framework 9 C#, VB, and the .NET Languages 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 C# Language Basics 18 Case Sensitivity 18 Commenting 18 Statement Termination 19 ■ CONTENTS vi Blocks 20 Variables and Data Types 20 Assignment and Initializers 22 Strings and Escaped Characters 24 Arrays 24 Enumerations 26 Variable Operations 27 Advanced Math 29 Type Conversions 29 Object-Based Manipulation 31 The String Type 32 The DateTime and TimeSpan Types 34 The Array Type 36 Conditional Logic 37 The if Statement 38 The switch Statement 39 Loops 40 The for Loop 40 The foreach Loop 41 The while loop 42 Methods 43 Parameters 44 Method Overloading 45 Optional and Named Parameters 46 Delegates 47 The Last Word 48 ■ Chapter 3: Types, Objects, and Namespaces 49 The Basics About Classes 49 Static Members 50 A Simple Class 51 ■ CONTENTS vii Building a Basic Class 51 Creating an Object 53 Adding Properties 54 Automatic Properties 56 Adding a Method 56 Adding a Constructor 57 Adding an Event 59 Testing the Product Class 60 Value Types and Reference Types 63 Assignment Operations 63 Equality Testing 64 Passing Parameters by Reference and by Value 64 Reviewing .NET Types 65 Understanding Namespaces and Assemblies 67 Using Namespaces 68 Importing Namespaces 69 Assemblies 70 Advanced Class Programming 71 Inheritance 71 Static Members 73 Casting Objects 74 Partial Classes 76 Generics 77 The Last Word 79 Part 2: Developing ASP.NET Applications 81 ■ Chapter 4: Visual Studio 83 The Promise of Visual Studio 83 Creating Websites 84 Creating an Empty Web Application 85 ■ CONTENTS viii Websites and Web Projects 89 The Hidden Solution Files 90 The Solution Explorer 91 Adding Web Forms 92 Migrating a Website from a Previous Version of Visual Studio 93 Designing a Web Page 95 Adding Web Controls 96 The Properties Window 98 The Anatomy of a Web Form 100 The Web Form Markup 100 The Page Directive 101 The Doctype 102 The Essentials of XHTML 104 Writing Code 110 The Code-Behind Class 110 Adding Event Handlers 110 Outlining 112 IntelliSense 113 Code Formatting and Coloring 117 Visual Studio Debugging 118 The Visual Studio Web Server 118 Single-Step Debugging 119 Variable Watches 124 The Last Word 125 ■ Chapter 5: Web Form Fundamentals 127 The Anatomy of an ASP.NET Application 127 ASP.NET File Types 128 ASP.NET Application Directories 129 Introducing Server Controls 130 HTML Server Controls 131 [...]... 49 1 Selecting Disconnected Data 49 2 Selecting Multiple Tables 49 4 Defining Relationships 49 5 The Last Word 49 8 ■ Chapter 15: Data Binding 49 9 Introducing Data Binding .49 9 Types of ASP.NET Data Binding 500 How Data Binding Works 500 Single-Value Data Binding 500 A Simple Data Binding Example... Using SiteMapPath Styles and Templates 43 2 Adding Custom Site Map Information .43 4 The TreeView Control 43 5 TreeView Properties 43 6 TreeView Styles 43 8 The Menu Control 44 2 Menu Styles 44 4 Menu Templates 44 5 The Last Word 44 8 Part 4: Working with Data 44 9 ■ Chapter 14: ... 41 6 Binding an Ordinary Page to a Site Map 41 6 Binding a Master Page to a Site Map 41 8 Binding Portions of a Site Map 42 0 The SiteMap Class 42 5 URL Mapping and Routing 42 7 URL Mapping 42 8 URL Routing 42 8 xiv ■ CONTENTS The SiteMapPath Control .43 0 Customizing the SiteMapPath 43 1... programming, including Pro Silverlight 4 in C# (Apress, 2010) and Pro WPF in C# 2010 (Apress, 2010) He’s also the coauthor of Pro ASP.NET 4 in C# 2010 (Apress, 2010) He lives in Toronto with his wife and daughters xxv ■ CONTENTS About the Technical Reviewer ■ Damien Foggon is a developer, writer, and technical reviewer in cutting-edge technologies and has contributed to more than 50 books on NET, C#, Visual... Simple Data Binding with Properties 5 04 Problems with Single-Value Data Binding 505 Using Code Instead of Simple Data Binding .506 Repeated-Value Data Binding 506 Data Binding with Simple List Controls 507 A Simple List Binding Example 508 Strongly Typed Collections 509 Multiple Binding 510 Data Binding with... 45 1 Understanding Databases 45 1 Configuring Your Database 45 3 SQL Server Express 45 3 Browsing and Modifying Databases in Visual Studio 45 4 The sqlcmd Command-Line Tool 45 7 SQL Basics 45 8 Running Queries in Visual Studio .45 9 The Select Statement 46 1 The SQL Update Statement .46 3 The... 2 24 Throwing Your Own Exceptions 2 24 Logging Exceptions 229 Viewing the Windows Event Logs .229 Writing to the Event Log .232 Custom Logs .2 34 A Custom Logging Class .236 Retrieving Log Information 237 Page Tracing 239 Enabling Tracing . 240 Tracing Information 240 ... Automatically Generating Columns 540 Defining Columns . 542 Formatting the GridView 546 Formatting Fields 546 Using Styles 547 Formatting-Specific Values 550 Selecting a GridView Row 552 Adding a Select Button .553 Using Selection to Create Master-Details Pages 5 54 Editing with the GridView... 40 1 Master Pages and Relative Paths .40 2 Advanced Master Pages 40 3 Style-Based Layouts 40 3 Code in a Master Page 40 8 Interacting with a Master Page Programmatically .40 9 The Last Word 41 0 ■ Chapter 13: Website Navigation .41 1 Site Maps 41 1 Defining a Site Map 41 2 Seeing a Simple Site Map in. .. Converting an HTML Page to an ASP.NET Page 131 View State 1 34 The HTML Control Classes 135 Adding the Currency Converter Code 138 Event Handling 140 Behind the Scenes with the Currency Converter 142 Error Handling 144 Improving the Currency Converter . 144 Adding Multiple Currencies 145 Storing . ROADMAP Pro ASP. NET 4 CMS Pro ASP. NET MVC 2 Framework Pro ASP. NET 4 in C# 2010 Pro C# 2010 and the .NET 4 Platform Beginning ASP. NET 4 in C# 2010 www.apress.com SOURCE CODE ONLINE Companion. version ISBN 978-1 -43 02-2608-6 9 78 143 0 226086 5 49 9 9 Beginning Beginning ASP. NET 4 in C# 2010 ■ ■ ■ Matthew MacDonald Beginning ASP. NET in C# 2010 Copyright © 2010 by. Author of Pro ASP. NET 4 in C# 2010 Pro Silverlight 4 in C# Pro WPF in C# 2010 ASP. NET: The Complete Reference US $49 .99 Shelve in: Programming Languages / C# User level: Beginning Intermediate THE

Ngày đăng: 29/06/2014, 13:20