0% found this document useful (0 votes)
25 views52 pages

Beginning ASP NET in VB NET From Novice To Professional 1st Edition Matthew Macdonald (Auth.) Sample

Beginning ASP.NET in VB.NET: From Novice to Professional is a comprehensive guide by Matthew MacDonald, published in 2004, aimed at teaching readers how to develop web applications using ASP.NET and Visual Basic. The book covers a wide range of topics, including the .NET framework, web form fundamentals, data management, and web services, structured in a way that progresses from basic concepts to advanced techniques. It is available in PDF format and includes various resources for further learning and application development.

Uploaded by

aileen6427joana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views52 pages

Beginning ASP NET in VB NET From Novice To Professional 1st Edition Matthew Macdonald (Auth.) Sample

Beginning ASP.NET in VB.NET: From Novice to Professional is a comprehensive guide by Matthew MacDonald, published in 2004, aimed at teaching readers how to develop web applications using ASP.NET and Visual Basic. The book covers a wide range of topics, including the .NET framework, web form fundamentals, data management, and web services, structured in a way that progresses from basic concepts to advanced techniques. It is available in PDF format and includes various resources for further learning and application development.

Uploaded by

aileen6427joana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Beginning ASP NET in VB NET From Novice to

Professional 1st Edition Matthew Macdonald (Auth.)


pdf version

Order now at [Link]


( 4.6/5.0 ★ | 203 downloads )

[Link]
novice-to-professional-1st-edition-matthew-macdonald-auth/
Beginning ASP NET in VB NET From Novice to Professional 1st
Edition Matthew Macdonald (Auth.) Pdf Download

EBOOK

Available Formats

■ PDF eBook Study Guide Ebook

EXCLUSIVE 2025 ACADEMIC EDITION – LIMITED RELEASE

Available Instantly Access Library


We have selected some products that you may be interested in
Click the link to download now or visit [Link]
for more options!.

Professional ASP NET 4 in C and VB 1st Edition Bill Evjen

[Link]
vb-1st-edition-bill-evjen/

Pro ASP NET 2 0 in C 2005 2nd Edition Matthew Macdonald

[Link]
matthew-macdonald/

Beginning ASP NET 3 5 In C and VB 1st Edition Imar


Spaanjaars

[Link]
edition-imar-spaanjaars/

Beginning ASP NET 4 5 in C and VB 1st Edition Imar


Spaanjaars

[Link]
edition-imar-spaanjaars/
Beginning VB 2008 From Novice to Professional 1st Edition
Christian Gross (Auth.)

[Link]
professional-1st-edition-christian-gross-auth/

Beginning Information Cards and CardSpace From Novice to


Professional Expert s Voice in Net 1st Edition Marc
Mercuri
[Link]
cardspace-from-novice-to-professional-expert-s-voice-in-net-1st-
edition-marc-mercuri/

ASP NET Website Programming Problem Design Solution VB NET


Edition Marco Bellinaso

[Link]
design-solution-vb-net-edition-marco-bellinaso/

Microsoft ASP NET coding strategies with the Microsoft ASP


NET team Matthew Gibbs

[Link]
with-the-microsoft-asp-net-team-matthew-gibbs/

Beginning C From Novice to Professional Beginning from


Novice to Professional 4th ed. Edition Ivor Horton

[Link]
professional-beginning-from-novice-to-professional-4th-ed-edition-
ivor-horton/
Beginning ASP NET in VB NET From Novice to
Professional 1st Edition Matthew Macdonald (Auth.)
Digital Instant Download
Author(s): Matthew MacDonald (auth.)
ISBN(s): 9781590592786, 1590592786
Edition: 1
File Details: PDF, 31.15 MB
Year: 2004
Language: english
Beginning [Link]
in VB .NET:
From Novice
to Professional
MATTHEW MACDONALD

APress Media, LLC


Beginning [Link] in VB .NET: From Novice to Professional
Copyright ©2004 by Matthew MacDonald
Originally published by Apress in 2004

Ali 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 owner and
the publisher.
ISBN 978-1-59059-278-6 ISBN 978-1-4302-0710-8 (eBook)
DOI 10.1007/978-1-4302-0710-8
Trademarked names may appear in this book. Rather than use a trademark symbol with every
occurrence of a trademarked name, we use the names only in an editorial fashion and to the
benefit of the trademark owner, with no intention of infringement of the trademark.
Technical Reviewer: Tim Verycruysse
Editorial Board: Dan Appleman, Craig Berry, Gary Cornell, Tony Davis, Steven Rycroft,
Julian Skinner, Martin Streicher, Jim Sumser, Karen Watterson, Gavin Wray, John Zukowski
Assistant Publisher: Grace Wong
Project Manager: Tracy Brown Collins
Copy Editor: Mark Nigara
Production Manager: Karl Brooks
Senior Production Editor: Kelly Wmquist
Proofreader: Lori Bring
Compositor: Susan Glinert
Indexer: John Collin
Artist: Christine Calderwood, Kinetic Publishing Services, LLC
Cover Designer: Kurt Krames
Manufacturing Manager: Tom Debolski

The information in this book is distributed on an "as is" hasis, 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 loving wife Faria
Contents at a Glance

About the Author .................................................................................................. xv


Acknowledgments ................................................................................................. xvii
Introduction .......................................................................................................... xix

Part One ASP. NET Introduction ....................................... 1

Chapter 1 The .NET Framework ................................................................. 3


Chapter 2 Setting Up Internet Information Services
and [Link] .............................................................................. 19
Chapter 3 Learning the Visual Basic • NET Language ................. 43
Chapter 4 Types, Objects, and Namespaces .................................... 73

Part Two Developing ASP. NET Applications .............. 97


Chapter 5 ASP. NET Applications .......................................................... 99
Chapter 6 Web Form Fundamentals ...................................................... 133
Chapter 7 Web Controls .......................................................................... 165
Chapter 8 Using Visual Studio • NET ............................................... 201
Chapter 9 Validation and Rich Controls ....................................... 233
Chapter 10 State Management ................................................................. 273
Chapter 11 Tracing, Logging, and Error Handling ..................... 305
Chapter 12 Deploying ASP. NET............................................................... 347

Part Three Working with Data .......................................... 363

Chapter 13 Introducing [Link] .......................................................... 365


Chapter 14 ADO. NET Data Access .......................................................... 387
Chapter 15 Data Binding .......................................................................... 431
Chapter 16 The DataList, DataGrid, and Repeater ..................... 457
Chapter 17 Files, Streams, and E-mail ........................................... 501
Chapter 18 Using XML ................................................................................ 529

v
Contents at a Glance

Part Four Web Services ...................................................... 569

Chapter 19 Web Services Architecture ............................................ 571

Chapter 20 Creating Web Services ..................................................... 587

Chapter 21 Using Web Services ............................................................ 615

Part Five Advanced ASP. NET ................................................. 643


Chapter 22 Component-Based Programming ........................................ 645

Chapter 23 Custom Controls .................................................................. 679

Chapter 24 Caching and Performance Tuning .................................. 725

Chapter 25 Implementing Security ..................................................... 759

Chapter 26 The IBuySpy Case Studies............................................... 797

Part Six ASP. NET Reference .......................................... 837

Chapter 27 HTML Server Controls ....................................................... 839


Chapter 28 Web Controls ......................................................................... 857

Chapter 29 Configuration Files .......................................................... 909

Index ....................................................................................................................... 935

vi
Contents

About the Author............................................................................................ xv


Acknowledgments ........................................................................................... xvii

Introduction ..................................................................................................... xix

Part One ASP. NET Introduction ........................................... 1

Chapter 1 The •NET Framework ......................................................... 3


The Evolution of Web Development ................................................................. 3
The .NET Framework ................................................................................................ 9
VB • NET, C#, and the • NET Languages ........................................................ 12
The Common Language Runtime .......................................................................... 14
The • NET Class Library ..................................................................................... ·15
Visual Studio .NET.............................................................................................. 16
The Last Word ........................................................................................................ 17

Chapter 2 Setting Up Internet Information Services


and ASP. NET ......................................................................... 19
Web Servers and You ........................................................................................... 19
Managing Websites ................................................................................................ 24
Installing ASP. NET.............................................................................................. 37
The Last Word ........................................................................................................ 42

Chapter 3 Learning the Visual Basic


•NET Language .................................................................... 43
The .NET Languages .............................................................................................. 43
The Evolution of VB • NET ................................................................................ 44
Variables and Data Types ................................................................................ 46
Variable Operations ........................................................................................... 52
Object-Based Manipulation .............................................................................. 56
Conditional Structures ..................................................................................... 62
Loop Structures .................................................................................................... 64

vii
Contents

Functions and Subroutines .............................................................................. 67


The Last Word ........................................................................................................ 71

Chapter 4 Types} Objects} and Namespaces ........................ 73

The Basics About Classes ................................................................................ 73


Building a Basic Class.................................................................................... 76
Value Types and Reference Types ................................................................ 85
Advanced Class Programming ........................................................................... 89
Understanding Name spaces and Assemblies ............................................... 92
The Last Word ........................................................................................................ 96

Part Two Developing ASP. NET Applications .............. 97

Chapter 5 ASP. NET Applications ................................................. 99

The Anatomy of an ASP. NET Application ................................................... 99


[Link] File Types ........................................................................................... 100
A Simple Application from Start to Finish ......................................... 104
Code-Behind .......................................................................................................... 110
The Global. as ax Application File ............................................................ 120
Understanding the ASP. NET Classes.......................................................... 123
ASP. NET Configuration.................................................................................... 125
The Last Word ...................................................................................................... 132

Chapter 6 Web Form Fundamentals............................................. 133

A Simple Page Applet ...................................................................................... 133


Improving the Currency Converter ............................................................ 144
A Deeper Look at HTML Control Classes ................................................. 150
The Page Class .................................................................................................... 156
The Last Word ...................................................................................................... 163

Chapter 7 Web Controls .................................................................... 165

Stepping Up to Web Controls ....................................................................... 165


Web Control Classes ......................................................................................... 169
List Controls ...................................................................................................... 174
Table Controls .................................................................................................... 177
AutoPostBack and Web Control Events ...................................................... 183
A Simple Web Page Applet .............................................................................. 190
The Last Word ...................................................................................................... 199

viii
Contents

Chapter 8 Using Visual Studio . NET ...................................... 201

The Promise of Visual Studio . NET ........................................................... 201


Starting a Visual Studio .NET Project .................................................. 202
Designing Web Pages ......................................................................................... 213
Writing Code ......................................................................................................... 217
Visual Studio .NET Debugging ...................................................................... 225
The Last Word ...................................................................................................... 232

Chapter 9 Validation and Rich Controls ............................ 233

The Calendar Control ....................................................................................... 233


The AdRotator ...................................................................................................... 239
Validation ............................................................................................................. 242
A Simple Validation Example ........................................................................ 246
Understanding Regular Expressions ........................................................... 252
Other Rich Controls ......................................................................................... 261
The Microsoft Internet Explorer Controls ............................................ 262
The Last Word ...................................................................................................... 272

Chapter 10 State Management ........................................................... 273

The Problem of State ....................................................................................... 273


View State ............................................................................................................. 274
Transferring Information .............................................................................. 281
Custom Cookies .................................................................................................... 285
Session State ...................................................................................................... 288
Session State Configuration ........................................................................ 294
Application State .............................................................................................. 300
An Overview of State Management Choices .............................................. 302
The Last Word ...................................................................................................... 303

Chapter 11 Tracing, Logging, and Error Handling ....... 305

Common Errors ...................................................................................................... 305


The .NET Exception Object ............................................................................ 308
Handling Exceptions ......................................................................................... 310
Throwing Your OWn Exceptions ...................................................................... 316
Logging Exceptions ............................................................................................ 319
Error Pages ........................................................................................................... 328
Page Tracing ......................................................................................................... 333
The Last Word ...................................................................................................... 345

ix
Contents

Chapter 12 Deploying ASP. NET ....................................................... 347

Making Your Website Visible ....................................................................... 347


Deploying a Simple Site ................................................................................ 348
Deploying with Visual Studio .NET .......................................................... 352
Migrating from ASP ........................................................................................... 360
The Last Word ...................................................................................................... 362

Part Three Working with Data ................................................ 363

Chapter 13 Introducing [Link] .................................................. 365

Introducing [Link] and Data Management ............................................. 365


The [Link] Object Model .............................................................................. 373
Comparing ADO and [Link]............................................................................ 383
The Last Word ...................................................................................................... 385

Chapter 14 [Link] Data Access .................................................. 387

About the [Link] Examples ......................................................................... 387


SQL Basics ............................................................................................................ 388
The Select Statement ...................................................................................... 390
The SQL Update Statement .............................................................................. 393
The SQL Insert Statement .............................................................................. 394
The SQL Delete Statement .............................................................................. 396
Accessing Data the Easy Way ....................................................................... 396
Creating a Connection .................................................................................... 397
Defining a Select Command............................................................................ 401
Updating Data ...................................................................................................... 407
Using Disconnected Data ................................................................................ 414
Updating Disconnected Data ......................................................................... 422
The Last Word ...................................................................................................... 430

Chapter 15 Data Binding .................................................................... 431

Introducing Data Binding .............................................................................. 431


Single- Value Data Binding ............................................................................ 433
Repeated- Value Data Binding ....................................................................... 440
Data Binding with Databases ....................................................................... 448
The Last Word ...................................................................................................... 455

X
Contents

Chapter 16 The DataList, DataGrid, and Repeater ....... 457

Introducing Templates ..................................................................................... 457


Using Templates with the DataList ........................................................... 457
Data Binding with Multiple Templates .................................................... 467
Comparing the Template Controls ............................................................... 472
Preparing Your List for Selection and Editing ................................. 481
Selecting Items .................................................................................................. 482
Editing Items ...................................................................................................... 485
Paging with the DataGrid .............................................................................. 494
Sorting with the DataGrid ............................................................................ 496
Sorting and Filtering with the DataView .............................................. 498
The Last Word ...................................................................................................... 500

Chapter 17 Files, Streams, and E-mail ................................. 501

Files and Web Applications .......................................................................... 501


File System Information ................................................................................. 502
Reading and Writing with Streams ............................................................. 513
Allowing File Uploads ..................................................................................... 521
Sending Mail ......................................................................................................... 524
The Last Word ...................................................................................................... 527

Chapter 18 Using XML ............................................................................. 529

XML 's Hidden Role in . NET ............................................................................ 529


XML Explained ...................................................................................................... 530
The XML Classes .................................................................................................. 536
XML Validation .................................................................................................... 552
XML Display and Transforms .......................................................................... 559
XML in ADO. NET .................................................................................................... 563
The Last Word ...................................................................................................... 567

Part Four Web Services ........................................................... 569

Chapter 19 Web Services Architecture ................................... 571

Internet Programming Then and Now........................................................... 571


Web Service Description Language ............................................................. 574
SOAP .......................................................................................................................... 580
Communicating with a Web Service ............................................................. 581
Web Service Discovery and UDDI ................................................................. 583
The Last Word ...................................................................................................... 586

xi
Contents

Chapter 20 Creating Web Services ............................................. 587

Web Service Basics ........................................................................................... 587


The StockQuote Web Service ......................................................................... 588
Documenting Your Web Service ..................................................................... 590
Testing Your Web Service .............................................................................. 592
Web Service Data Types .................................................................................. 597
The [Link] Intrinsic Objects ................................................................... 602
Other Web Service Options ............................................................................ 605
The Last Word ...................................................................................................... 613

Chapter 21 Using Web Services ..................................................... 615

Consuming a Web Service ................................................................................ 615


Using the Proxy Class .................................................................................... 625
An Example with TerraService ..................................................................... 633
Windows Clients ................................................................................................. 639
The Last Word ...................................................................................................... 641

Part Five Advanced ASP. NET .................................................. 643

Chapter 22 Component-Based Programming ............................. 645

Why Use Components? ......................................................................................... 645


Component Jargon ............................................................................................... 647
Creating a Simple Component ....................................................................... 650
The Component Class ......................................................................................... 650
Properties and State ...................................................................................... 656
Database Components ......................................................................................... 659
Using COM Components ...................................................................................... 672
The Last Word ...................................................................................................... 677

Chapter 23 Custom Controls ............................................................ 679

User Controls ...................................................................................................... 679


Derived Custom Controls ................................................................................ 695
Dynamic Graphics ............................................................................................... 718
The Last Word...................................................................................................... 724

xii
Contents

Chapter 24 Caching and Performance Tuning ...................... 725


Designing for Scalability ............................................................................ 725
Profiling ............................................................................................................... 729
Caching .................................................................................................................... 738
Output Caching .................................................................................................... 738
Data Caching ......................................................................................................... 748
The Last Word ...................................................................................................... 757

Chapter 25 Implementing Security .............................................. 759


Determining Security Requirements ........................................................... 759
The [Link] Security Model .......................................................................... 760
Forms Authentication ....................................................................................... 768
Windows Authentication ................................................................................... 784
Impersonation ...................................................................................................... 793
The Last Word ...................................................................................................... 795

Chapter 26 The IBuySpy Case Studies ...................................... 797


The IBuySpy Store .............................................................................................. 802
The IBuySpy Portal ............................................................................................ 827
The Last Word ...................................................................................................... 836

Part Six ASP. NET Reference ............................................... 837

Chapter 2 7 HTML Server Controls ................................................ 839


HTML Controls ...................................................................................................... 839
HtmlButton ............................................................................................................. 841

Chapter 28 Web Controls ..................................................................... 857


Basic Web Controls ............................................................................................ 857
List Controls ...................................................................................................... 873
Rich Controls ...................................................................................................... 879
Validation Controls ......................................................................................... 886
ValidationSummary .............................................................................................. 890
Data Controls ...................................................................................................... 891

xiii
Contents

Chapter 29 Configuration Files .................................................. 909

Configuration Files ......................................................................................... 909


Configuration File Sections ....................................................................... 909

Index ..................................................................................................................... 935

xiv
About the Author
Matthew MacDonald is an author, educator, and
MCSD developer. He's a regular contributor to
programming journals such as Inside Visual Basic,
and the author of over a dozen books about .NET
programming, including The Book of VB .NET
(No Starch), [Link]: The Complete Reference
(Osborne McGraw-Hill), Microsoft Visual Basic .NET
Programmer's Cookbook (Microsoft Press), and
Microsoft .NET Distributed Applications (Microsoft
Press). In a dimly remembered past life he studied
English literature and theoretical physics.

XV
Acknowledgments
No AUTHOR COULD COMPLETE a book without a small army of helpful individuals. I'm
deeply indebted to the whole Apress team, including Kelly Wmquist and Tracy Brown
Collins, who helped everything move swiftly and smoothly, Mark Nigara, who performed
the copy edit, and many other individuals who worked behind the scenes indexing pages,
drawing figures, and proofreading the final copy. I owe a special thanks to Gary Cornell,
who always offers invaluable advice about projects and the publishing world. He's helped
to build a truly unique company with Apress.
I'd also like to thank those who were involved with the first edition of this book at
Osborne McGraw- Hill. These include Emma Acker and Jane Brownlow, who saw the
book through its many stages and occasional growing pains, and Tim Verycruysse, who
provided valuable technical review. In addition, I'd like to thank Julian Skinner, who
provided additional feedback on some of the early chapters, and all the readers who
caught errors, including Mark Nicholson, Steven Mandel, illi Hom, Jason Schmidt, Jim
Storey, and many more who took time out to report problems and ask good questions.
This list is by no means complete!
Finally, I'd never write any book without the support of my wife and these special
individuals: Nora, Razia, Paul, and Hamid. Thanks everyone!

xvii
Introduction
ASP {ACTIVE SERVER PAGES) is a relatively new technology that has already leapt
through several stages of evolution. It was introduced about seven years ago as an easy
way to add dynamic content to ordinary web pages. Since then, it has grown into some-
thing much more ambitious: a platform for creating advanced web applications, including
e-commerce shops, data-driven portal sites, and just about anything else you can find
on the Internet.
[Link] is the latest version of ASP, and it represents the most dramatic change yet.
[Link], developers no longer need to paste together a jumble ofHIML and script
code in order to program the Web. Instead, you can create full-scale web applications
using nothing but code and a design tool like Visual Studio .NET. The cost of all this
innovation is the learning curve. In order to get up to speed with ASP. NET, you'll need to
learn a whole new programming language (Visual Basic .NET) and an entirely new way
to write web pages.
Beginning [Link] in VB .NET: Novice to Pro assumes that you want to master
[Link], starting from the basics. Using this book, you'll build your knowledge until
you understand the concepts, techniques, and best practices for writing sophisticated
web applications. The journey is long, but it's also satisfying. At the end of the day,
you'll find that [Link] allows you to tackle challenges that are simply out of reach on
many other platforms. You'll also become a part of the fast -growing ASP. NET developer
community.

About This Book


This book explores [Link], which is a core part of Microsoft's new .NET Framework.
The .NET Framework isn't a single application-it's actually a collection of different
technologies bundled into one marketing term. The .NET Framework includes new
languages like C# and VB .NET (the successor to Visual Basic 6), an engine for hosting
programmable web pages and web services (ASP. NET), a new model for interacting
with databases ([Link]), and a class library stocked with tools for everything from
sending e-mail to encrypting a password. In order to master [Link], you need to learn
about each of these ingredients.
This book covers all these topics from the ground up. As a side effect, you'll find
yourself learning many techniques that will interest any .NET developer, even those
who create Windows applications. For example, you'll learn about component-based
programming, structured error handling, and how to access files, XML, and relational
databases. You'll also learn the key topics that are required for web programming, like
state management, web controls, and web services. By the end of this book, you'll be
ready to create your own rich web applications, and make them available over the Internet

xix
Introduction

;;-i!
.·~
·--
NOTE This book has a single goal: to be as relentlessly practical as possible.
I take special care not to leave you hanging in the places where other
[Link] books abandon their readers. For example, when encountering
a new technology, you'll not only learn how it works, but why (and when)
you should use it. I also highlight common questions and best practices
with tip boxes and sidebars at every step of the way. Finally, if a topic is
covered in this book, it's covered correctly. This means that you won't
learn how to perform a task without learning about potential drawbacks
and the problems you might run into-and how you can safeguard your-
selfwith real-world code.

Who Should Read This Book


This book is aimed at anyone who wants to create dynamic websites with [Link].
Ideally, you'll have experience with a previous version of the Visual Basic or VBScript
programming language. If not, you should be familiar with basic progranuning concepts
Uoops, conditional structures, arrays, and so on), whether you've learned them in Java,
C, Pascal, Thring, or a completely different programming language. This is the only
requirement for reading this book.
Understanding HTML will help, but it isn't required. [Link] works at a higher level,
allowing you to deal with full-featured web controls instead of raw HTML. You also
won't need any knowledge of XML, because Chapter 18 covers it in detail.

NOTE .NET is an entirely new programming framework, which means


even experienced developers will feel a little like beginners. For that reason,
this book begins with the fundamentals: VB .NET and C# syntax, the
basics of object-oriented programming, and the philosophy of the .NET
Framework. If you've never worked with Visual Basic before, you can
spend a little more time with the syntax review in Chapter 2 to pick up
everything you need to know. If you aren't familiar with the ideas of
object-oriented programming, Chapter 3 fills in the blanks with a quick,
but comprehensive review of the subject. The rest of the book builds on
this foundation, from [Link] basics to advanced examples that show
the techniques you'll use in real-world web applications.

What You Need to Read This Book


If you're just starting with ASP. NET, you should check that you have all the necessary
ingredients to create, test, and host web applications.

XX
Introduction

• To develop on the .NET Framework, your computer requires Windows 2000,


Wmdows XP, or Wmdows 2003 Server. You'll also need to install the optional liS
(Internet Information Services) component, as described in Chapter 2. Wmdows XP
Home Edition is not supported.

• The only software you need to create [Link] applications is the .NET Framework.
You can download the .NET SDK (software development kit) from
http: I /[Link]. You can also order it on CD from the Microsoft Evaluation
and Resource Center at http: I /microsoft. order- 2. com/ developertools. Finally,
if you're using Visual Studio .NET, you don't need to install the .NET Framework
separately.

• For best results, you should use Visual Studio. NET, which comes complete with
countless productivity enhancements and indispensable timesavers. You don't
need Visual Studio .NET to read this book and create [Link] applications, but
you will find that it simplifies your life a great deal. Visual Studio .NET is available in
numerous editions, including cheaper fixed-language and academic versions
(see http: I /msdn. microsoft. com/vstudio/productinfo for more information).
Chapter 8 describes everything you need to know about using VISual Studio .NET.

TIP If you don't have a copy of Visual Studio .NET, you can use
the freely downloadable Web Matrix tool (available at
http: I /www. asp. net/webmatrix). Web Matrix is very similar to Visual
Studio .NET, although it uses a slightly different coding style than the
one used in this book. However, in order to use this book's sample code
with a minimum of trouble, you should use Visual Studio .NET.

Code Samples
In order to master [Link], you need to experiment with it. One of the best ways to learn
[Link] is to try out the code samples for this book, examine them, and dive in with your
own modifications. To obtain the sample code, surf to http: I /www. prosetech. com. You'll
also find some links to additional resources, and any updates or errata that affect the book.

VB or C#?
[Link] applications can be designed with almost any .NET language, including Visual
Basic .NET, C#, or J#. This book describes the syntax for Microsoft's most popular
language, Visual Basic .NET. VB .NET represents the natural migration path for existing
ASP developers who are familiar with VB Script or developers who have worked with a
previous version of Visual Basic. But as you'll discover in first chapter, [Link] languages
are created equal, and VB .NET and C# match features blow-for-blow, with only a few
minor discrepancies.

xxi
Introduction

[Link] 1.1
The .NET Framework is currently available in two versions: the original version 1.0
(released in 2002), and version 1.1 (released in 2003). There are very few noticeable
differences between the two versions, because 1.1 mainly consists of minor bug fixes
and performance enhancements. You can use this book to program with either version
of .NET. Any differences are clearly highlighted in the text.
Visual Studio .NET, the professional design tool I recommend for creating [Link]
websites, also exists in two versions. Visual Studio .NET 2002 is designed to work with
.NET 1.0, while Visual Studio .NET 2003 supports .NET 1.1. Although VS .NET 2002 and
VS .NET 2003 are very similar, they use a different format for project and solution files.
The code samples for this book include VS .NET 2002 project files, which you can open
in either version of Visual Studio .NET. For more information, consult the [Link]
file included with the code download.

TIP Before you can open a web project with Visual Studio .NET, you'll
need to understand how to create virtual directories. For that reason,
I recommend that you read Chapter 5 before you attempt to install the
sample code.

Contents Overview
This book is divided into six parts. Unless you've already had experience with the .NET
Framework, the most productive way to read this book is in order from start to finish.
Chapters later in the book sometimes incorporate features that were introduced earlier
in order to create more well-rounded and realistic examples. On the other hand, ifyou're
already familiar with the .NET platform, the Visual Basic .NET language, and object-
oriented programming, you'll be able to make short work of the first part of this book.

Part One: [Link] Introduction


You could start coding an [Link] application right away by following the examples in
the second part of this book. But in order to really master [Link], you need to under-
stand a few fundamental concepts about the .NET Framework.
Chapter 1 sorts through the Microsoft jargon, and explains what the .NET Framework
really does, and why we need it. Chapter 2 gets you started with [Link] and liS
(Internet Information Services), the web hosting software that's built into the Wmdows
operating system. You'll learn the steps needed to install the software and create virtual
directories. Next, Chapter 3 introduces you to VB .NET with a comprehensive language
reference, and Chapter 4 explains the basics of modern object-oriented programming
with VB .NET.

xxii
Introduction

Part Two: Developing [Link] Applications


The second part of this book delves into the heart of ASP. NET programming, and intro-
duces its new event-based model. In Chapter 5, you'll learn how to organize multiple
web forms into [Link] application. In Chapter 6 and Chapter 7, you'll learn how to
program a web page's user interface through a layer of objects called server controls.
You'll also see some of the most remarkable ASP. NET controls, like the full-featured
Calendar and the new input validators in Chapter 9.
The second part also explores the fundamentals of ASP. NET programming. Chapter 8
introduces the Visual Studio .NET design environment. Chapter 10 describes different
strategies for state management, and Chapter 11 presents different techniques for
handling errors. Finally, Chapter 12 walks you through the steps for deploying your
application to a web server. Taken together, these chapters contain all the core concepts
you need to design web pages and create a basic ASP. NET website.

Part Three: Working with Data


Almost all software needs to work with data, and web applications are no exception.
Chapter 13 begins your exploration into the world of data by considering [Link]-
Microsoft's new technology for interacting with relational databases. Chapter 14
demonstrates practical [Link] code. Chapter 15 and Chapter 16 explain how to
use data binding and the advanced [Link] data controls to create web pages that
integrate attractive, customizable data displays with automatic support for paging,
sorting, and editing.
Chapter 17 moves out of the database world and considers how to interact with files
and send e-mail. Chapter 18 broadens the picture even further, and describes how
[Link] applications can use the XML support that's built into the .NET Framework.

Part Four: Web Services


Web services are an entirely new introduction [Link], and one of Microsoft's most
heavily promoted new technologies. Using web services, you can share pieces of
functionality on your web server with other applications on other computers. Best of
all, the whole process works with open standards like XML, thereby ensuring that
applications written in different programming languages and running on different
operating systems can interact without a hitch.
Chapter 19 presents an overview of web service technology. Chapter 20 shows how
to create a basic web service, and then enhance it with caching, custom objects, and
transactions. Chapter 21 shows how to use your web service in another web or Wmdows
application, and presents a sample page that interacts with Microsoft's TerraService
over the Internet.

xxiii
Introduction

Part Five: Advanced [Link]


This part includes the advanced topics you can use to take your web applications that
extra step. Chapter 22 and Chapter 23 consider how you can create reusable compo-
nents and web controls for [Link] applications. Chapter 24 demonstrates how a
careful use of caching can boost the performance of almost any web application.
Chapter 25 explains how to use different security models to safeguard your site or
provide subscription services.
Chapter 26 shifts focus to the IBuySpy case studies. Microsoft provides these full-
featured sample sites to demonstrate the best way to design an e-commerce application
and web portal. Though they are incredibly useful examples, they're also hard to
understand at first glance, and they provide little developer documentation. Chapter 26
dissects the IBuySpy samples, and shows how they use the concepts and features
demonstrated throughout this book.

Part Six: [Link] Reference


The last part of this book provides a detailed reference for web controls and the config-
uration files. Chapter 27 and Chapter 28list each web control with its picture, control tag,
and list of properties. Chapter 29 dissects every setting in the ASP. NET configuration files.
You can turn to these chapters once you've learned the ASP. NET basics for quick,
at-a-glance information.

Feedback
This book has the ambitious goal of being the best tutorial and reference for ASP. NET.
Toward that end, your comments and suggestions are extremely helpful. You can send
complaints, adulation, and everything in between directly to apress@prosetech. com.
I can't solve your [Link] problems or critique your own code, but I will benefit from
information about what this book did right and wrong (and what it may have done in
an utterly confusing way). You can also send comments about the website support for
this book to the same address.

xxiv
Another Random Scribd Document
with Unrelated Content
cannot be conceived by us, but as a progressive series, of which our
separate feelings are parts; the remembrance of the events of our
life, whenever we take any distant retrospect of them, being like the
remembrance of the space, which we have traversed in a journey,—
an indistinct continuity of length, as truly divisible, in our conception,
into the separate events which we remember, as the space, which
we remember to have traversed, into its separate variety of scenes.
Time, then, or remembered succession, we found to involve, not
metaphorically, as is commonly said, but truly and strictly, in its very
essence, the notions of length and divisibility,—the great elements of
extension; and whatever other feelings may be habitually and
uniformly associated with these, will involve, of course, these
elementary notions.
The series of muscular feelings, of which the infant is conscious,—in
incessantly closing and opening his little hand,—must, on these
principles, be accompanied with the notion,—not, indeed, of the
existence of his hand, or of any thing external,—but of a certain
length of succession; and each stage of the contraction, by frequent
renewal, gradually becomes significant of a particular length,
corresponding with the portion of the series. When any hard body,
therefore, is placed in the infant's hand,—though he cannot, indeed,
have any knowledge of the object, or of the hand,—he yet feels,
that he can no longer perform the accustomed contraction,—or, to
speak more accurately,—since he is unacquainted with any parts that
are contracted, he feels, that he can no longer produce his
accustomed series of feelings; and he knows the quantity of
contraction, which remained to be performed, or rather the length of
the series, which remained to be felt. The place of this remaining
length is now supplied by a new feeling, partly muscular, and partly
the result of the affection of the compressed organ of touch,—and is
supplied by the same feeling, at the same point of the series, as
often, as he attempts to renew the contraction, while the body
remains within his hand. The tactual feeling, therefore,—whatever it
may be,—becomes, by this frequent repetition, associated with the
notion of that particular progressive series, or length, of which it
thus uniformly supplies the place; and at last becomes
representative of this particular length, precisely in the same
manner, as, in the acquired perceptions of vision, certain shades of
colour become representative of distance, to which they have, of
themselves, no resemblance or analogy, whatever; and we thus
learn to feel length, as we learn to see length,—not directly by the
mere affections of our tactual or visual organs, but by the associated
notions which they suggest.
If time,—as perceived by us in the continued series of our feelings,—
do involve conceptual length and divisibility, it seems, indeed,
scarcely possible, that, in the circumstances supposed, the notions
supposed should not arise,—that the infant should be conscious of a
regular series of feelings, in the contraction of its fingers and arms,
and yet that portions of this series should not become significant of
various proportional lengths;—and, if the notion of certain
proportional lengths do truly accompany certain degrees of
progressive contraction, it seems equally impossible, according to
the general principles of our mental constitution, that the compound
tactual and muscular feeling, which must arise in every case, in
which any one of these degrees of contraction is impeded, should
not become associated with the notion of that particular length, of
which it supplies the place, so as at last to become truly
representative of it.
In this manner, I endeavoured to explain to you, how our knowledge
of the mere length of bodies may have been acquired, from varieties
of length that are recognized as coexisting and proximate, and are
felt to unite, as it were, and terminate in our sensation of resistance,
which interrupts them equally, and interrupts always a greater
number of the coexisting truths, in proportion to the size of the body
compressed; and, in a similar manner, our notions of the other
dimensions of bodies, which are only these varieties of length in
different directions. I cannot conclude this summary, however,
without recalling to your attention, a very simple experiment, which
I requested you to make for yourselves,—an experiment, that, even
in the unfavourable circumstances in which it must now be tried, is
yet, I conceive, demonstrative of the influence of mere time, as an
element of that complex notion, which we have been examining,
when the more rapid measurements of vision,—which are
confessedly not original but acquired,—are excluded. If, in passing
our finger, with different degrees of slowness or rapidity, along the
same surface, with our eyes shut,—even though we should
previously know the exact boundaries of the extent of surface,—we
feel it almost impossible not to believe,—and but for the contrary
evidence of vision, could not have hesitated a single moment in
believing,—that this extent is greater or less, according as the time
employed in performing exactly the same quantity of motion, with
exactly the same force of pressure, on the same quantity of our
organ of touch, may have been greater or less,—it must surely be
admitted, that the notion of the length, which thus uniformly varies
with the time, when all other circumstances are the same, is not
absolutely independent of the time,—or it must, in like manner, be
believed, that our notion of visual distance, which varies with the
distribution of a few rays of light on the small expanse of the optic
nerve, is yet independent of those faint shades of colouring,
according to the mere varieties of which, it seems at one time to lay
open to our view a landscape of many miles, and at another time to
present to us, as it were before our very eyes, an object of scarcely
an inch in diameter. The greater dimness, and diminished size of a
few objects in the back ground of a picture, which is in itself one
coloured plane of light, does not more truly seem to increase the line
of distance of those objects, than, in the other case, the increased
slowness of the motion of our hand along any surface, seems to
lengthen the line which separates one of its boundaries from the
other.
That we now seem to perceive extension, immediately by touch,
cannot be denied; and, in a case so obscure as this,—with our very
limited knowledge, and our very limited power of adding to this
knowledge,—it may seem the most prudent, and perhaps even the
most suitable,—as it is, without all question, by far the easiest part,
—to acquiesce in the opinion, that the perception, which now seems
immediate, was so originally,—that the belief of the presence of an
external figured body, is, by the very constitution of our nature,
attached to a certain affection of the mere organ of touch. But, since
there are circumstances,—as we have seen,—which show this
opinion, when very nicely examined, to be inadmissible, we may, at
least, attempt to proceed a little farther, if we do this with a
sufficient sense of the very great difficulty of the attempt, in relation
to our power and knowledge, and consequently with a very humble
assurance, as to the certainty of any opinion which we may be led to
form. To know the mind well, is to know its weaknesses as well as
its powers; and it is precisely in a case of this sort, that he, whose
knowledge is least imperfect, will be the best judge of its
imperfection, and, therefore, the least disposed to put complete
reliance on it in his own speculations,—or to assert it dogmatically,
when he offers it, as all opinions, on so very obscure a subject,
should be offered, to the inquiry, rather than to the undoubting
assent.
The analysis, I own, is one which must require a considerable effort
of attention on your part, because it is truly one of the most subtile
on which I could call you to enter. But you must be aware, that this
subtlety is in the nature of the very inquiry itself; since it is an
inquiry into the elements and progressive growth of feelings, which
seem to us, at present, simple and immediate, and that the
alternatives, therefore, are not those of greater or less subtlety and
refinement of analysis, but of attempting the analysis, or abandoning
it altogether.
Before proceeding farther, in our inquiry with respect to the origin of
the notion of extension, it may, however, be of advantage, to take a
short retrospect of the progress which we have already made; for, if
we have found nothing more, we have, at least, as I conceive, found
reason to reject a considerable part of our former belief on the
subject, which, though a negative acquisition, is yet a very important
one. Though we should not be able to discover the true source of
the notion which we seek, it is something, at least, to know, that we
have little reason to expect to find it, where we have uniformly been
accustomed to seek it.
In the first place, then, we have seen the fallacy of the supposition,
that our knowledge of extension may be easily accounted for, by the
similarity in figure of the compressed part of the organ of touch to
the compressing body, since the notion of extension is not a state of
the material organ, compressed and figured, which, as mere matter,
however exquisitely organized, is as little capable of this notion, as
of smell, or taste, love or aversion, but, a state of the mind itself,
which is susceptible of shape or pressure, being as little square,
when it perceives a square, as when it perceives a circle; and any
affection of which, therefore, may be supposed as much to follow
any one shape, as any other shape of the mere external organ. If,
indeed, as this explanation most strangely seems to assume, we
could be supposed to have any previous knowledge of the shape of
our organ of touch, nothing more would be necessary, for we should
then have a perfect knowledge of extension, though no other
extended body but our own organ of touch were in existence. To
refer us to the organ is, however, only to bring the very same
difficulty one step nearer, since previously to the application of an
external body, the mind has as little knowledge of the shape of its
organ of touch, as it has of the body compressing it; and it is
manifestly most absurd, to ascribe the origin of our knowledge of
extension, to our knowledge of the resemblance in figure of an
external body to our organ; since this very knowledge of the
resemblance must imply the previous knowledge of the figure of
both, and consequently of that very extension, which, according to
this supposition, must be known to us before it is known.
In the second place, we have seen, that, if the configuration of the
sensorial organ were the only circumstance necessary, to induce,
immediately, in mind, the notion of figure, this notion should
accompany every sensation of every kind; the smell of a rose, for
example, as much as the pressure of a cube or a sphere: for the
nervous expansion, in the organ of smell, and in every other organ,
is of a certain figure, before sensation, during sensation, and after
sensation, as much as the nervous expansion of the organ of touch.
And, though we were to confine ourselves wholly to this organ, the
nervous matter in it is, at all times, of a certain shape, as much
when there is no pressure on it, as when it is exposed to such
pressure; yet the mere figure of the organ of touch, is not then
accompanied with the mental notion of its figure; nor is this the
case, merely when the sense is quiescent, but, in many cases, in
which it is affected in the most lively manner; as, for example, when
we are exposed to great cold or heat, in which cases, the shape of
this very tactual organ, thus strongly affected, is as much
unperceived by us, as when there is no affection of it whatever.
Lastly, which is a point of much more importance, because it has
relation to the only philosophic view of touch, as the immediate
organ of extension; the view, in which the mere configuration of the
compressed organ, as similar to that of the compressing body, is laid
out of account, and the immediate belief of extension is supposed to
depend on the original constitution of the mind, by which its
affections have been arranged, so as to correspond with certain
affections of the bodily organs; the mental state which constitutes
the perception of a square, arising immediately when the organ of
touch is affected, in a certain manner, as that mental state which
constitutes the sensation of the fragrance of a rose, arises
immediately, when the organ of smell is affected, in a certain
manner; this opinion too, philosophic as it is, compared with those
which we before considered, though, in truth, it only assumes the
point in question, without attempting to solve any difficulty,
supposed to be connected with it, we have yet found to be as little
tenable, as the opinions that suppose the mental notion of figure to
depend on the peculiar figure of the compressed material organ. The
consideration which, as I stated in my last Lecture, seems to me
decisive on this point, is, that, if touch inform us of extension
immediately, as smell informs us of fragrance, sight of colour, and
hearing of sound; it must do this in every instance, without relation
to particular figure, as smell, sight, and hearing, extend to all
odours, hues, and sounds; for it would certainly be, as I said, a very
strange abuse of the license of supposition, to imagine that we
perceive a square immediately by touch, but not a circle; or a circle,
but not a square; or any one figure, but not any other figure. In
short, if figure be the direct primary object of touch, as sight is of
vision, we should feel immediately every form impressed, as we see
immediately every colour. It is only when the figures are very simple
and regular, however, such as we might be supposed to have easily
learned, in the same manner as we learn, visually, to judge of
distances, that we are able to discover them, as it were,
immediately, by touch; and, even when we are able, in this manner,
to determine the species of figure, that is to say, the mere outline of
a body, we are rarely able to determine the exact magnitude which
that outline comprehends; yet, as our organ must be affected by
each part of the compressing surface, by the central parts, as much
as by the exterior parts which form its outline, and by these, as
much as by the central parts; and as every feeling which the organ
directly affords, must be immediate, when there is no change of the
position, or other circumstances of the object, that might vary the
sensation, we should, if mere touch communicated to us the
knowledge supposed, be able to determine, exactly and instantly,
the magnitude and figure; or, it is evident, that the determination of
magnitude and figure must depend wholly, or in part, on something
that is different from touch. The magnitude we are far from being
able to discover exactly, even of simple figures; and when the form
is very irregular, and we know nothing more, than that a certain
body is pressed against our hand,—the magnitude and figure are
alike difficult to be discovered; so difficult, that I may safely say, that
no one, who makes the experiment, will find, on opening his eyes,
that his tactual or intellectual measurement has, in any one case,
been exact, or his notion of the figure half so distinct as it now is,
after a single glance. Can we then think that it is by mere touch we
discover figure, as exactly as by the glance of our mature vision,—
that we discover it, in all its varieties, originally by touch, and as
accurately at first, as after innumerable trials,—when we discover it,
only in a few cases, that are previously familiar to us, and even in
these very imperfectly? The determination of the form impressed, in
which we are almost conscious of a sort of intellectual measurement,
has surely a much greater resemblance to the perceptions, which we
term acquired, than to those which are immediate. In vision, for
example, when the original power of that sense has been
strengthened and enriched, by the acquisitions which it is capable of
receiving from other sources, we see a long line of distance before
us; and the small distances with which we are familiar, we
distinguish with sufficient accuracy; but, in our visual measurement
of greater distances, we are almost certain to err, taking often the
less for the greater, and the greater for the less. It is precisely the
same in touch. When a small body, which we have never seen, is
pressed upon our hand, we are able, if its surface be square, or
circular, or of any other form, with which we are well acquainted, to
determine its figure, without much hesitation; because we have
learned, tactually, to distinguish these regular figures. But, in
endeavouring to determine, in this manner, by touch alone, the
figure of any irregular body, less familiar to us, though, as a direct
object of sense, if touch be the sense of figure, it should be equally
and as immediately tangible as the most regular form, we feel a
hesitation of the same sort, as when we attempt to ascertain by our
eye, the exact distance of a remote object. To know extension or
figure, is to know, not one point merely in the surface of a body, but
many continuous points; and if, when the surface, is circular, we
know these continuous points, and their relation to each other,
immediately on pressure, we must know, as immediately, the same
points and their relations, though the surface comprehending them,
instead of being circular, should be of an outline more irregular. We
certainly cannot know this irregular surface to have any extension at
all, unless we know some parts of it; and, when the pressure is
uniform from every point, and the organ of touch uniform, on which
the pressure is made, it would be absurd to suppose, that we know
fifty, or eighty, of the hundred points which form the impressing
surface, but cannot determine its figure, because we are ignorant of
the twenty of fifty remaining points; when these remaining points
are acting on our organ of touch, in exactly the same manner as the
fifty or eighty which we know, and when, if the surface containing
merely the same number of points, had been circular, or of any other
single form, as familiar to us, the whole hundred points would have
been known to us equally and at once.
When our perceptions of form, then, are so various and irregular,
and are more or less quick and precise, exactly as the shape which
we endeavour to determine, has more or less resemblance to shapes
that are familiar to us, it does not seem too bold an inference to
conclude, that the knowledge of figure, which, as all extension that
is capable of being perceived by us, must have some boundary, is
nothing more than the knowledge of extension, is not the state of
mind originally and immediately subsequent to affections of our
organs of touch, any more than the perception of distance is the
state of mind originally and immediately subsequent to affections of
our organ of sight; and the very striking analogy of these two cases,
it will be of great importance for you to have constantly in view; as it
will render it less difficult for you to admit many circumstances, with
respect to touch, which you might otherwise have been slower to
conceive. That we should seem to perceive extension immediately
by touch, though touch originally, and of itself, could not have
afforded this perception, will not then appear more wonderful, than
the apparently immediate perception of distance by the eye, which,
of itself, originally afforded us no perception of that sort; nor the
impossibility of feeling a body, without the notion of it, as extended,
be more wonderful than the similar impossibility of separating colour
from extension, in the case of distant vision. Above all, the analogy
is valuable, as shewing the closeness and indissolubleness of the
union, which may be formed of feelings that have in themselves no
resemblance. What common properties, could we have conceived in
vision, and that absolute blindness, which has never had a single
sensation from light! and, yet, it is worthy of remark, that the
perceptions of the blind, in consequence of this singular power of
association, form truly the most important part of those very
perceptions of vision, of which, as a whole, they are unfortunately
deprived. We do not merely see with our eyes, what we may have
felt with our hands; but our eyes, in the act of vision, have
borrowed, as it were, those very sensations.
The proof, that our perception of extension by touch, is not an
original and immediate perception of that sense, is altogether
independent of the success of any endeavour which may be made,
to discover the elements of the compound perception. It would not
be less true, that touch does not afford it, though we should be
incapable of pointing out any other source, from which it can be
supposed to be derived. Of the difficulty of the attempt, and the
caution with which we should venture to form any conclusion on the
subject, I have already spoken. But the analysis, difficult as it is, is
too interesting not to be attempted, even at the risk, or perhaps I
should rather say, with the very great probability, of failure.
In such an analysis, however, though we are to proceed with the
greatest caution, it may be necessary to warn you, that it is a part of
this very caution, not to be easily terrified, by the appearance of
paradox, which the result of our analysis may present. This
appearance we may be certain, that any analysis which is at all
accurate must present, because the very object of the analysis is to
shew, that sensations, which appear simple and direct, are not
simple,—that our senses, in short, are not fitted, of themselves, to
convey that information, which they now appear, and through the
whole course of our memory have appeared to us instantly to
convey. It is very far, indeed from following, as a necessary
consequence, that every analysis of our sensations which affords a
paradoxical result, is, therefore, a just one—for error may be
extravagant in appearance as well as in reality. But it may truly be
regarded as a necessary consequence, that every accurate and
original analysis of our sensations must afford a result, that, as first
stated, will appear paradoxical.
To those who are wholly unacquainted with the theory of vision,
nothing certainly can seem, as first stated, more absurd than the
assertion, that we see, not with our eyes merely, but chiefly by the
medium of another organ, which the blind possess in as great
perfection as ourselves, and which, at the moment of vision, may
perhaps be absolutely at rest. It must not surprise you, therefore,
though the element which seems to me to form the most important
constituent of our notion of extension should in like manner, as first
stated to you, seem a very unlikely one.
This element is our feeling of succession, or time—a feeling, which
necessarily, involves the notion of divisibility or series of parts, that is
so essential a constituent of our more complex notion of matter,—
and to which notion of continuous divisibility, if the notion of
resistance be added, it is scarcely possible for us to imagine, that we
should not have acquired, by this union, the very notion of physical
extension,—that which has parts, and that which resists our effort to
grasp it.
That memory is a part of our mental constitution, and that we are
thus capable of thinking of a series of feelings, as successive to each
other, the experience of every moment teaches us sufficiently. This
succession frequently repeated, suggests immediately, or implies the
notion of length, not metaphorically, as is commonly said, but as
absolutely as extension itself: and, the greater the number of the
successive feelings may have been, the greater does this length
appear. It is not possible for us to look back on the years of our life,
since they form truly a progressive series, without regarding them as
a sort of length, which is more distinct indeed, the nearer the
succession of feelings may be to the moment at which we consider
them, but which, however remote, is still felt by us as one continued
length, in the same manner, as when, after a journey of many
hundred miles, we look back, in our memory, on the distance over
which we have passed, we see, as it were, a long track of which
some parts, particularly the nearer parts, are sufficiently distinct, but
of which the rest seems lost in a sort of distant obscurity. The line of
our long journeying—or, in other words, that almost immeasurable
line of plains, hills, declivities, marshes, bridges, woods,—to
endeavour to comprehend which in our thought, seems an effort as
fatiguing as the very journey itself—we know well, can be divided
into those various parts:—and, in like manner, the progressive line of
time—or, in other words, the continued succession, of which the joy,
the hope, the fragrance, the regret, the melody, the fear, and
innumerable other affections of the mind, were parts, we feel that
we can mentally divide into those separate portions of the train.
Continuous length and divisibility, those great elementary notions of
space, and of all that space contains, are thus found in every
succession of our feelings. There is no language in which time is not
described as long or short,—not from any metaphor—for no mere
arbitrary metaphor can be thus universal, and inevitable, as a form
of human thought—but because it is truly impossible for us to
consider succession, without this notion of progressive divisibility
attached to it: and it appears to us as absurd to suppose, that by
adding, to our retrospect of a week, the events of the month
preceding, we do not truly lengthen the succession, as it would be to
suppose, that we do not lengthen the line of actual distance, by
adding, to the few last stages of a long journey, the many stages
that preceded it.
It is this spreading out of life into a long expanse, which allows man
to create, as it were, his own world. He cannot change, indeed, the
scene of external things. But this may be said, in one sense, to be
the residence only of his corporeal part. It is the moral scene in
which the spirit truly dwells; and this adapts itself, with harmonious
loveliness, or with horror as suitable, to the character of its pure or
guilty inhabitant. If but a single moment of life,—a physical point, as
it were, of the long line—could be reviewed at once, conscience
would have little power of retribution. But he who has lived, as man
should live, is permitted to enjoy that best happiness which man can
enjoy,—to behold, in one continued series, those years of benevolent
wishes or of heroic suffering, which are at once his merit and his
reward. He is surrounded by his own pure thoughts and actions,
which, from the most remote distance, seem to shine upon him
wherever his glance can reach; as in some climate of perpetual
summer, in which the inhabitant sees nothing but fruits and
blossoms, and inhales only fragrance, and sunshine, and delight. It
is in a moral climate as serene and cloudless, that the destined
inhabitant of a still nobler world moves on, in that glorious track,
which has heaven before, and virtue and tranquillity behind;—and in
which it is scarcely possible to distinguish, in the immortal career,
when the earthly part has ceased, and the heavenly begins.
Is it in metaphor only, that a youth and maturity, and old age of
guilt, seem to stretch themselves out in almost endless extent, to
that eye which, with all its shuddering reluctance, is still condemned
to gaze on them,—when, after the long retrospect seems finished,
some fraud, or excess, or oppression, still rises and adds to the
dreadful line—and when eternity itself, in all the horrors which it
presents, seems only a still longer line of the same dreadful species,
that admits of no other measure, than the continued sufferings, and
remembrance, and terrors that compose it!
It is a just and beautiful observation of an ancient Stoic, that time
which is past is like something consecrated to the gods, over which
fortune and mortality have no longer any power, and that, dreadful
as it must be to the wicked, to whom their own memory is an object
of terror, it still, to the virtuous, offers itself as a consolation or joy—
not in single moments like the present hour, but in all that long
series of years which rises before us, and remains with us at our
bidding. “Ille qui multa ambitiosè cupiit, superbè contempsit,
insidiosè decepit, avarè rapuit, prodigè effudit,—necesse est
memoriam suam timeat. Atqui hæc est pars temporis nostri sacra ac
dedicata, omnes humanos casus supergressa, extra regnum fortunæ
subducta; quam non inopia, non metus, non morborum incursus
exagitat. Hæc nec turbari nec eripi potest; perpetua ejus et intrepida
possessio est. Singuli tantùm dies, et hi per momenta, præsentis
sunt: at præteriti temporis omnes, cum jusseris aderunt, ad
arbitrium tuum se inspici ac detineri patientur.”
By those, who can look back on years that are long past, and yet
say, that the continued progress, or the length and the shortness of
time, are only metaphorical expressions, it might be said with equal
justness, that the roundness of a sphere, is a metaphor, or the
angularity of a cube. We do not more truly consider the one as
angular and the other as round, than we consider the time to be
continuously progressive, in which we considered, first the one
figure, and then the other, and inquired into the properties of each.
That which is progressive must have parts. Time, or succession, then
involves the very notions of longitudinal extension and divisibility,
and involves these, without the notion of any thing external to the
mind itself;—for though the mind of man had been susceptible only
of joy, grief, fear, hope, and the other varieties of internal feeling,
without the possibility of being affected by external things, he would
still have been capable of considering these feelings, as successive
to each other, in a long continued progression, divisible into separate
parts. The notions of length, then, and of divisibility, are not
confined to external things, but are involved, in that very memory,
by which we consider the series of the past,—not in the memory of
distant events only, but in those first successions of feeling, by which
the mind originally became conscious of its own permanence and
identity. The notion of time, then, is precisely coeval with that of the
mind itself; since it is implied in the knowledge of succession, by
which alone, in the manner formerly explained to you, the mind
acquires the knowledge of its own reality, as something more than
the mere sensation of the present moment.
Conceiving the notion of time, therefore, that is to say of feelings
past and present, to be thus one of the earliest notions which the
infant mind can form, so as to precede its notions of external things,
and to involve the notions of length and divisibility, I am inclined to
reverse exactly the process commonly supposed; and, instead of
deriving the measure of time from extension, to derive the
knowledge and original measure of extension from time. That one
notion or feeling of the mind may be united indissolubly with other
feelings, with which it has frequently coexisted, and to which, but for
this coexistence, it would seem to have no common relation, is
sufficiently shown by those phenomena of vision to which I have
already so frequently alluded.
In what manner, however, is the notion of time peculiarly associated
with the simple sensation of touch, so as to form, with it, the
perception of extension? We are able, in the theory of vision, to
point out the coexistence of sensations which produce the
subsequent union; that renders the perception of distance
apparently immediate. If a similar coexistence of the original
sensations of touch, with the notion of continued and divisible
succession, cannot be pointed out in the present case, the opinion
which asserts it, must be considered merely as a wild and
extravagant conjecture.
The source of such a coexistence is not merely to be found, but is at
least as obvious, as that which is universally admitted in the case of
vision.
Before I proceed, however, to state to you, in what way I conceive
the notion to be acquired, I must again warn you of the necessity of
banishing, as much as possible, from your view of the mind of the
infant in this early process, all those notions of external things,
which we are so apt to regard as almost original in the mind,
because we do not remember the time, when they arose in our own.
As we know well, that there are external things, of a certain form,
acting on our organs, which are also of a certain form, it seems so
very simple a process, to perceive extension—that is to say, to know
that there exist without us those external forms, which really exist—
that to endeavour to discover the mode, in which extension, that
now appears so obvious a quality of external things, is perceived by
us, seems to be a needless search, at a distance, for what is already
before our very eyes. And it will be allowed, that all this would,
indeed, be very easy to a mind like ours, after the acquisitions of
knowledge which it has made; but the difficulty of the very question
is, how the mind of the infant makes these acquisitions, so as to
become like ours. You must not think of a mind, that has any
knowledge of things external, even of its own bodily organs, but of a
mind simply affected with certain feelings, and having nothing but
these feelings to lead it to the knowledge of things without.
To proceed, then,—The hand is the great organ of touch. It is
composed of various articulations, that are easily moveable, so as to
adapt it readily to changes of shape, in accommodation to the shape
of the bodies which it grasps. If we shut our hand gradually, or open
it gradually, we find a certain series of feelings, varying with each
degree of the opening or closing, and giving the notion of succession
of a certain length. In like manner, if we gradually extend our arms,
in various directions, or bring them nearer to us again, we find that
each degree of the motion is accompanied with a feeling that is
distinct, so as to render us completely conscious of the progression.
The gradual closing of the hand, therefore, must necessarily give a
succession of feelings,—a succession, which, of itself, might, or
rather must, furnish the notion of length, in the manner before
stated, the length being different, according to the degree of the
closing; and the gradual stretching out of the arm gives a succession
of feelings, which, in like manner, must furnish the notion of length,
—the length being different according to the degree of the
stretching of the arm. To those who have had opportunities of
observing infants, I need not say, how much use, or rather what
constant use, the future inquirer makes of his little fingers and arms;
by the frequent contraction of which, and the consequent renewal of
the series of feelings involved in each gradual contraction, he cannot
fail to become so well acquainted with the progress, as to distinguish
each degree of contraction, and, at last, after innumerable
repetitions, to associate with each degree the notion of a certain
length of succession. The particular contraction, therefore, when
thus often repeated, becomes the representative of a certain length,
in the same manner as shades of colour, in vision become ultimately
representative of distance,—the same principle of association, which
forms the combination in the one case, operating equally in the
other.
In these circumstances of acquired knowledge,—after the series of
muscular feelings, in the voluntary closing of the hand, has become
so familiar, that the whole series is anticipated and expected, as
soon as the motion has begun,—when a ball, or any other
substance, is placed for the first time in the infant's hand, he feels
that he can no longer perform the usual contraction,—or, in other
words, since he does not fancy that he has muscles which are
contracted, he feels that the usual series of sensations does not
follow his will to renew it,—he knows how much of the accustomed
succession is still remaining; and the notion of this particular length,
which was expected, and interrupted by a new sensation, is thus
associated with the particular tactual feeling excited by the pressure
of the ball,—the greater or less magnitude of the ball preventing a
greater or less portion of the series of feelings in the accustomed
contraction. By the frequent repetition of this tactual feeling, as
associated with that feeling, which attends a certain progress of
contraction, the two feelings at last flow together, as in the acquired
perceptions of vision; and when the process has been repeated with
various bodies innumerable times, it becomes, at last, as impossible
to separate the mere tactual feeling, from the feeling of length, as to
separate the whiteness of a sphere, in vision, from that convexity of
the sphere, which the eye, of itself, would have been forever
incapable of perceiving.
As yet, however, the only dimension of the knowledge, of which we
have traced the origin, is mere length; and it must still be explained,
how we acquire the knowledge of the other dimensions. If we had
had but one muscle, it seems to me very doubtful, whether it would
have been possible for us, to have associated with touch any other
notion than that of mere length. But nature has made provision, for
giving us a wider knowledge, in the various muscles, which she has
distributed over different parts, so as to enable us to perform
motions in various directions at the same instant, and thus to have
coexisting series of feelings, each of which series was before
considered as involving the notion of length. The infant bends one
finger gradually on the palm of his hand; the finger, thus brought
down, touches one part of the surface of the palm, producing a
certain affection of the organ of touch, and a consequent sensation;
and he acquires the notion of a certain length, in the remembered
succession of the muscular feelings during the contraction:—he
bends another finger; it, too, touches a certain part of the surface of
the palm, producing a certain feeling of touch, that coexists and
combines, in like manner, with the remembrance of a certain
succession of muscular feelings. When both fingers move together,
the coexistence of the two series of successive feelings, with each of
which the mind is familiar, gives the notion of coexisting lengths,
which receive a sort of unity, from the proximity in succession of the
tactual feelings in the contiguous parts of the palm which they
touch,—feelings, which have before been found to be proximate,
when the palm has been repeatedly pressed along a surface, and
the tactual feelings of these parts, which the closing fingers touch at
the same moment, were always immediately successive,—as
immediately successive, as any of the muscular feelings in the series
of contraction. When a body is placed in the infant's hand, and its
little fingers are bent by it as before, sometimes one finger only is
impeded in its progress, sometimes two, sometimes three,—and he
thus adds to the notion of mere length, which would have been the
same, whatever number of fingers had been impeded, the notion of
a certain number of proximate and coexisting lengths, which is the
very notion of breadth; and with these, according as the body is
larger or smaller, is combined always the tactual affection produced
by the pressure of the body, on more, or fewer, of the interior parts
of the palm, and fingers, which had before become, of themselves,
representative of certain lengths, in the manner described; and the
concurrence of these three varieties of length, in the single feeling of
resistance, in which they all seem to meet, when an incompressible
body is placed within the sphere of the closing fingers,—however
rude the notions of concurring dimensions may be, or rather must
be, as at first formed,—seems at least to afford the rude elements,
from which, by the frequent repetition of the feeling of resistance,
together with the proximate lengths, of which it has become
representative, clearer notions of the kind may gradually arise.
The progressive contractions of the various muscles which move the
arms, as affording similar successions of feelings, may be considered
in precisely the same light, as sources of the knowledge of
extension; and, by their motion in various directions, at the same
time with the motion of the fingers, they concur powerfully, in
modifying, and correcting, the information received from these. The
whole hand is brought, by the motion of the arm, to touch one part
of the face or body; it is then moved, so as to touch another part,
and, with the frequent succession of the simple feelings of touch, in
these parts, is associated the feeling of the intervening length,
derived from the sensations that accompanied the progressive
contraction of the arm. But the motion is not always the same; and,
as the same feeling of touch, in one part, is thus followed by various
feelings of touch in different parts, with various series of muscular
feelings between, the notion of length in various directions, that is to
say, of length in various series commencing from one power, is
obtained in another way. That the knowledge of extension, or in
other words, the association of the notion of succession with the
simple feelings of touch, will be rude and indistinct at first, I have
already admitted; but it will gradually become more and more
distinct and precise: as we can have no doubt, that the perception of
distance by the eye, is, in the first stages of visual association, very
indistinct, and becomes clearer after each repeated trial. For many
weeks or months, all is confusion in the visual perceptions, as much
as in the tactual and muscular. Indeed, we have abundant evidence
of this continued progress of vision, even in mature life, when, in
certain professions that require nice perceptions of distance, the
power of perception itself, by the gradual acquisitions which it
obtains from experience, seems to unfold itself more and more, in
proportion to the wants that require it.
The theory of the notion of extension, of which I have now given
you but a slight outline, might, if the short space of these Lectures
allowed sufficient room, be developed with many illustrations, which
it is now impossible to give to it. I must leave you, in some measure,
to supply these for yourselves.
It may be thought, indeed, that the notion of time, or succession, is,
in this instance, a superfluous incumbrance of the theory, and that
the same advantage might be obtained, by supposing the muscular
feelings themselves, independently of the notion of their succession,
to be connected with the notion of particular lengths. But this
opinion, it must be remarked, would leave the difficulty precisely as
before; and sufficient evidence in confutation of it, may be found in
a very simple experiment, which it is in the power of any one to
make. The experiment I cannot but consider as of the more value,
since it seems to me,—I will not say decisive, for that is too
presumptuous a word,—but strongly corroborative of the theory,
which I have ventured to propose; for it shows, that, even after all
the acquisitions, which our sense of touch has made, the notion of
extension is still modified, in a manner the most striking and
irresistible, by the mere change of accustomed time. Let any one,
with his eyes shut, move his hand, with moderate velocity, along a
part of a table, or any other hard smooth surface, the portion, over
which he presses, will appear of a certain length; let him move his
hand more rapidly, the portion of the surface pressed will appear
less; let him move his hand very slowly, and the length, according to
the degree of the slowness, will appear increased, in a most
wonderful proportion. In this case, there is precisely the same
quantity of muscular contraction, and the same quantity of the organ
of touch compressed, whether the motion be rapid, moderate, or
slow. The only circumstance of difference is the time, occupied in
the succession of the feelings; and this difference is sufficient to give
complete diversity to the notion of length.
If any one, with his eyes shut, suffer his hand to be guided by
another, very slowly along any surface unknown to him, he will find
it impossible to form any accurate guess as to its length. But it is not
necessary, that we should be previously unacquainted with the
extent of surface, along which the motion is performed; for the
illusion will be nearly the same, and the experiment, of course, be
still more striking, when the motion is along a surface with which we
are perfectly familiar, as a book which we hold in our hand, or a desk
at which we are accustomed to sit.
I must request you, not to take for granted the result which I have
now stated, but to repeat for yourselves an experiment, which it is
so very easy to make, and which, I cannot but think is so very
important, as to the influence of mere difference of time, in our
estimation of longitudinal extent. It is an experiment, tried,
unquestionably, in most unfavourable circumstances, when our
tactual feelings, representative of extension, are so strongly fixed, by
the long experience of our life; and yet, even now, you will find, on
moving your hand, slowly and rapidly, along the same extent of
surface, though with precisely the same degree of pressure in both
cases, that it is as difficult to conceive the extent, thus slowly and
rapidly traversed, to be the same, as it is difficult to conceive the
extent of visual distance to be exactly the same, when you look
alternately through the different ends of an inverted telescope. If
when all other circumstances are the same, the different visual
feelings, arising from difference of the mere direction of light, be
representative of length, in the one case,—the longer or shorter
succession of time, when all other circumstances are the same, has
surely as much reason to be considered as representative of it, in
the other case.
Are we, then, to believe, that the feeling of extension, or, in other
words, of the definite figure of bodies, is a simple feeling of touch,
immediate, original, and independent of time; or is there not rather
reason to think, as I have endeavoured to show, that it is a
compound feeling, of which time, that is to say, our notion of
succession, is an original element?
LECTURE XXV.
ON THE DISTINCTION BETWEEN SENSATION
AND PERCEPTION,—AND BETWEEN THE
PRIMARY AND SECONDARY QUALITIES
OF MATTER.

My last Lecture, Gentlemen, was chiefly employed in considering the


nature of that complex process which takes place in the mind, when
we ascribe the various classes of our sensations to their various
external objects,—to the analysis of which process we were led, by
the importance which Dr Reid has attached to the distinction of
sensation and perception;—a sensation, as understood by him, being
the simple feeling that immediately follows the action of an external
body on any of our organs of sense, considered merely as a feeling
of the mind; the corresponding perception being a reference of this
feeling to the external body as its cause.
The distinction I allowed to be a convenient one, if the nature of the
complex process which it expresses be rightly understood. The only
question that seemed, philosophically, of importance, with respect to
it, was, whether the perception in this sense,—the reference of the
sensation to its external corporeal cause,—imply, as Dr Reid
contends, a peculiar mental power, coextensive with sensation, to be
distinguished by a peculiar name in the catalogue of our faculties, or
be not merely one of the results of a more general power, which is
afterwards to be considered by us,—the power of association,—by
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

[Link]

You might also like