Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter Kit (2006)

.pdf
Скачиваний:
32
Добавлен:
17.08.2013
Размер:
13.24 Mб
Скачать

www.GetPedia.com

Click on your interest section for more information :

Acne

Fitness Equipment

Political

Advertising

Forums

Positive Attitude Tips

Aerobics & Cardio

Game

Pay-Per-Click Advertising

Affiliate Revenue

Goal Setting

Public Relations

Alternative Medicine

Golf

Pregnancy

Attraction

Dealing with Grief & Loss

Presentation

Online Auction

Hair Loss

Psychology

Streaming Audio & Online Music

Finding Happiness

Public Speaking

Aviation & Flying

Computer Hardware

Real Estate

Babies & Toddler

Holiday

Recipes & Food and Drink

Beauty

Home Improvement

Relationship

Blogging, RSS & Feeds

Home Security

Religion

Book Marketing

Humanities

Sales

Book Reviews

Humor & Entertainment

Sales Management

Branding

Innovation

Sales Telemarketing

Breast Cancer

Inspirational

Sales Training

Broadband Internet

Insurance

Satellite TV

Muscle Building & Bodybuilding

Interior Design & Decorating

Science Articles

Careers, Jobs & Employment

Internet Marketing

Internet Security

Casino & Gambling

Investing

Search Engine Optimization

Coaching

Landscaping & Gardening

(SEO)

Coffee

Language

Sexuality

College & University

Leadership

Web Site Promotion

Cooking Tips

Leases & Leasing

Small Business

Copywriting

Loan

Software

Crafts & Hobbies

Mesothelioma & Asbestos

Spam Blocking

Creativity

Cancer

Spirituality

Credit

Business Management

Stocks & Mutual Fund

Cruising & Sailing

Marketing

Strategic Planning

Currency Trading

Marriage & Wedding

Stress Management

Customer Service

Martial Arts

Structured Settlements

Data Recovery & Computer

Medicine

Success

Backup

Meditation

Nutritional Supplements

Dating

Mobile & Cell Phone

Tax

Debt Consolidation

Mortgage Refinance

Team Building

Debt Relief

Motivation

Time Management

Depression

Motorcycle

Top Quick Tips

Diabetes

Music & MP3

Traffic Building

Divorce

Negotiation

Vacation Rental

Domain Name

Network Marketing

Video Conferencing

E-Book

Networking

Video Streaming

E-commerce

Nutrition

VOIP

Elder Care

Get Organized - Organization

Wealth Building

Email Marketing

Outdoors

Web Design

Entrepreneur

Parenting

Web Development

Ethics

Personal Finance

Web Hosting

Exercise & Fitness

Personal Technology

Weight Loss

Ezine Marketing

Pet

Wine & Spirits

Ezine Publishing

Philosophy

Writing

Fashion & Style

Photography

Article Writing

Fishing

Poetry

Yoga

Wrox’s ASP.NET 2.0

Visual Web Developer™ 2005

Express Edition Starter Kit

David Sussman and Alex Homer

Wrox’s ASP.NET 2.0

Visual Web Developer™ 2005

Express Edition Starter Kit

David Sussman and Alex Homer

Wrox’s ASP.NET 2.0 Visual Web Developer™ 2005 Express Edition Starter Kit

Published by

Wiley Publishing, Inc.

10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com

Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana

ISBN-13: 978-0-7645-8807-5

ISBN-10: 0-7645-8807-9

Manufactured in the United States of America

10 9 8 7 6 5 4 3 2 1

1MA/SR/RS/QV/IN

Library of Congress Control Number is available from the publisher.

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 please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Visual Web Developer is a trademark of Microsoft Corporation in the United States and/or other countries. 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.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.

"Microsoft" is a registered trademark of Microsoft Corporation in the United States and/or other countries and is used by Wiley Publishing, Inc. under license from owner. Wrox® ASP.NET 2.0 Visual Web Developer™ 2005 Express Edition Starter Kit is an independent publication not affiliated with Microsoft Corporation.

 

Credits

Senior Acquisitions Editor

Vice President & Executive Group Publisher

Jim Minatel

Richard Swadley

Development Editor

Vice President and Publisher

Kevin Shafer

Joseph B. Wikert

Technical Editors

Project Coordinator

Dan Mahary

Michael Kruzil

Richard Purchas

Graphics and Production Specialists

Production Editor

Lauren Goddard

Pamela Hanley

Denny Hager

Copy Editor

Barbara Moore

Alicia B. South

Foxxe Editorial Services

Quality Control Technicians

Editorial Manager

Laura Albert

Mary Beth Wakefield

Leeann Harney

Production Manager

Jessica Kramer

Proofreading and Indexing

Tim Tate

 

TECHBOOKS Production Services

About the Authors

David Sussman is a hacker in the traditional sense of the word. That’s someone who likes playing with code and working out how things work, which is why he spends much of his life working with beta software. Luckily, this coincides with writing about new technologies, giving him an output for his poor English and grammar. He lives in a small village in the Oxfordshire countryside. Like many programmers everywhere, he has an expensive hi-fi, a big TV, and no life. You can contact Dave through his own company, ipona Limited: davids@ipona.co.uk.

Alex Homer is a computer geek and Web developer with a passion for ASP.NET. Although he has to spend some time doing real work (a bit of consultancy and training, and the occasional conference session), most of his days are absorbed in playing with the latest Microsoft Web technology and then writing about it. Living in the picturesque wilderness of the Derbyshire Dales in England, he is well away from the demands of the real world—with only an Internet connection to maintain some distant representation of normality. But, hey, what else could you want from life? You can contact Alex through his own software company, Stonebroom Limited: alex@stonebroom.com.

Contents

Acknowledgments

ix

Introduction

xi

Chapter 1: Getting Started

1

About the Example Application

2

Installing Visual Web Developer

3

Step by Step — Using the Setup Wizard

3

Step by Step — Installing the PPQ Example Files

7

Viewing the PPQ Example Database

10

Step by Step — Viewing the PPQ Database

10

Reading and Displaying Data with ASP.NET

20

Summary

30

Chapter 2: Designing a Web Site

31

Designing a Web Site

31

Making Web Sites Accessible

32

Multilingual Web Sites and Globalization

32

Designing the Appearance of the Site

33

Templates and Master Pages

34

Navigation and Menus

35

Text Styles and Style Sheets

35

Designing the Underlying Workings of the Site

36

Data Access

36

Building a Master Page and Content Page

37

Creating the Page Structure as a Master Page

37

Choosing the Correct Element and Control Type

48

Adding the Navigation Links

48

Building Your First Content Page

55

Converting an Existing Page to a Content Page

60

Checking for Accessibility

63

Summary

65

Contents

Chapter 3: Building the PPQ Database

67

Designing the PPQ Database

68

Storing the Menu Items Data

68

Applying the Rules of Normalization

69

Applying the Remaining Normalization Rules

70

Storing the Orders Data

72

The OrderItems Table

73

The Final Database Design

74

Creating and Modifying Databases in VWD

76

The Table Designer Window

78

The Query Window

80

Creating a New Database

81

Creating the PPQ OrderItems Table

82

Defining Relationships between Tables

88

Defining Relationships in the Table Designer

88

Defining Relationships with a Database Diagram

90

Extracting and Displaying the Menu Items

94

Extracting Data with a Custom SQL Statement

94

Creating a Stored Procedure

101

Using a View Instead of a Table or Stored Procedure

104

Summary

105

Chapter 4: Accessing and Displaying Data

107

Data Source and Data Display Controls

108

The Object-Oriented and Event-Driven Architecture

109

About the GridView Control

110

Using Different Column Types in a GridView

111

Using Data Display Control Templates

117

The DetailsView and FormView Controls

123

Using a DetailsView and FormView Control

123

Summary

127

Chapter 5: Displaying Nested and XML Data

129

Building Nested Data Displays

130

Creating Nested Data Displays Declaratively

131

Writing Code to Access and Display Nested Data

143

The DataReader and DataSet Objects

144

Using a DataReader with a Data Source Control

144

Generating a Single DataSet with Relationships

145

How the Code in the ShowMenu.aspx Page Works

153

vi

 

Contents

User Controls and Binding to XML Data

157

Building the Delivery Costs Page

158

Building the Text Links User Control

162

Converting the XML with an XSLT Style Sheet

163

Creating the User Control

164

Converting Parts of a Page into a User Control

170

Summary

170

Chapter 6: Managing and Editing Data

173

Data Source Controls

173

Adding New Rows

186

Summary

193

Chapter 7: Placing an Order

195

The Order Process

196

Understanding Classes

197

Creating the Shopping Cart

198

The Shopping Cart Classes

198

The Shopping Cart Data Layer

212

The ObjectDataSource Control

212

The Data Layer Classes

213

Creating the Order Page

219

The Shopping Cart Page

225

Summary

234

Chapter 8: The Checkout Process

235

Paying for the Order

235

Collecting the Delivery Address

239

Collecting the Payment Details

245

Confirming the Order

248

Completing the Order

253

Understanding Exception Handling

260

Understanding Transactions

262

Summary

263

Chapter 9: Security and Deployment

265

Configuring Security

265

Modifying the Menu

273

vii