Pro ASP.NET 3.5 in C# 2008: Includes Silverlight 2

Front Cover
Apress, Dec 23, 2008 - Computers - 1520 pages

ASP.NET 3.5 is Microsoft’s principal standard for creating dynamic web pages on the Windows platform. Pro ASP.NET 3.5 in C# 2008 raises the bar for high–quality, practical advice on learning and deploying Microsoft’s dynamic web solution.

This edition is updated with everything you need to integrate Silverlight 2.0 and SQL Server 2008 into your ASP.NET applications. You will learn about Silverlight’s exciting features so that your ASP projects can be rich in visual flair and compelling to the user.

Seasoned .NET professionals Matthew MacDonald and Mario Szpuszta explain how you can get the most from this groundbreaking technology. They cover ASP.NET 3.5 as a whole, illustrating both the brand–new features and the functionality carried over from previous versions of ASP. This book will give you the knowledge you need to code real ASP.NET 3.5 applications in the best possible style.

 

What people are saying - Write a review

We haven't found any reviews in the usual places.

Selected pages

Contents

Introducing ASPNET
3
The Early Web Development World
4
ASPNET Is Integrated with the NET Framework
5
ASPNET Is Multilanguage
7
ASPNET Is Hosted by the Common Language Runtime
9
ASPNET Is ObjectOriented
10
ASPNET Is Multidevice and Multibrowser
12
The Story Continues
13
User Controls
641
Creating a Simple User Control
642
Converting a Page to a User Control
643
Adding Code to a User Control
644
Adding Properties
645
Using Custom Objects
647
Adding Events
650
Exposing the Inner Web Control
653

ASPNET 35
14
NET 35 Service Pack 1
18
Silverlight
19
Summary
20
Visual Studio
21
The NET Development Model
22
The Visual Studio IDE
23
Websites and Web Projects
24
Multitargeting
27
Designing a Web Page
28
The Visual Studio IDE
34
Solution Explorer
36
Document Window
37
Error List and Task List
38
Server Explorer
40
Adding Assembly References
41
IntelliSense and Outlining
44
The Code Model
46
How CodeBehind Files Are Connected to Pages
49
How Control Tags Are Connected to Page Variables
50
How Events Are Connected to Event Handlers
51
Web Projects
53
Creating a Web Project
54
Migrating a Website from a Previous Version of Visual Studio
56
Visual Studio Debugging
57
SingleStep Debugging
58
Variable Watches
61
Advanced Breakpoints
62
Visual Studio Macros
63
The Web Development Helper
65
Summary
67
Web Forms
69
HTML Forms
70
Dynamic User Interface
71
TheASPNET Event Model
72
Automatic Postbacks
73
View State
75
XHTML Compliance
80
Web Forms Processing Stages
84
Page Framework Initialization
85
User Code Initialization
86
Event Handling
87
Cleanup
88
The Page As a Control Container
90
Showing the Control Tree
91
The Page Header
95
Dynamic Control Creation
96
The Page Class
97
Session Application and Cache
98
Response
100
Server
102
User
105
Accessing the HTTP Context in Another Class
111
Summary
112
Server Controls
113
The Server Control Hierarchy
114
HTML Server Controls
116
The HtmlControl Class
117
The HTML Server Control Classes
118
Setting Style Attributes and Other Properties
120
Programmatically Creating Server Controls
121
Handling ServerSide Events
123
Web Controls
125
The WebControl Base Class
127
Basic Web Control Classes
128
Units
130
Colors
131
Focus
133
The Default Button
134
Scrollable Panels
135
The List Controls
138
The Selectable List Controls
140
The BulletedList Control
142
Input Validation Controls
144
The Validation Process
145
The BaseValidator Class
146
The RequiredFieldValidator Control
148
The CompareValidator Control
149
The CustomValidator Control
152
The ValidationSummary Control
154
Using the Validators Programmatically
155
Validation Groups
156
Rich Controls
158
The AdRotator Control
159
The Calendar Control
161
Summary
163
ASPNET Applications
165
The Application Domain
166
Application Lifetime
167
Application Directory Structure
168
The globalasax Application File
169
Application Events
171
Demonstrating Application Events
173
ASPNET Configuration
174
The webconfig File
177
systemweb Settings
181
Reading and Writing Configuration Sections Programmatically
185
The Website Administration Tool WAT
188
Extending the Configuration File Structure
190
Encrypting Configuration Sections
194
NET Components
196
Creating a Component
197
Using a Component Through the App_Code Directory
198
Using a Component Through the Bin Directory
199
Extending the HTTP Pipeline
201
HTTP Handlers and HTTP Modules
202
Creating a Custom HTTP Handler
204
Configuring a Custom HTTP Handler
205
Registering HTTP Handlers Without Configuring IIS
206
Creating an Advanced HTTP Handler
208
Creating an HTTP Handler for NonHTML Content
210
Creating a Custom HTTP Module
213
Summary
216
State Management
217
View State
220
A View State Example
221
Storing Objects in View State
222
Retaining Member Variables
225
Assessing View State
226
View State Security
228
Transferring Information Between Pages
229
CrossPage Posting
231
Cookies
238
Session State
239
Using Session State
241
Configuring Session State
242
Securing Session State
248
Application State
249
Static Application Variables
251
Summary
253
Data Access
255
ADONET Fundamentals
257
The ADONET Architecture
258
Standardization in ADONET
260
FundamentalADONET Classes
261
The Connection Class
262
Testing a Connection
264
Connection Pooling
265
Connection Statistics
267
The Command and DataReader Classes
268
The DataReader Class
269
The ExecuteReader Method and the DataReader
270
The ExecuteScalar Method
275
The ExecuteNonQuery Method
276
Using Parameterized Commands
279
Calling Stored Procedures
281
Transactions
283
Transactions and ASPNET Applications
284
Isolation Levels
288
Savepoints
290
ProviderAgnostic Code
291
Create Objects with Factory
292
A Query with ProviderAgnostic Code
293
Summary
294
Data Components and the DataSet
295
The Data Package
296
The Stored Procedures
298
The Data Utility Class
299
Testing the Database Component
305
Disconnected Data
307
Web Applications and the DataSet
308
XML Integration
309
The DataAdapter Class
311
Filling a DataSet
312
Working with Multiple Tables and Relationships
313
Searching for Specific Rows
317
Using the DataSet in a Data Access Class
318
Data Binding
319
Sorting with a DataView
320
Filtering with a DataView
321
Advanced Filtering with Relationships
323
Calculated Columns
324
Typed DataSets
326
Custom TableAdapters
327
Creating a Typed DataSet
328
Dissecting the Typed DataSet
330
Using the Typed DataSet
333
Summary
335
Data Binding
337
SingleValue Binding
338
Other Types of Expressions
340
RepeatedValue Binding
344
Data Source Controls
351
The Page Life Cycle with Data Binding
352
The SqlDataSource
353
Parameterized Commands
356
Handling Errors
360
Updating Records
361
Deleting Records
365
Inserting Records
366
The ObjectDataSource
367
Selecting Records
368
Updating Records
373
The Limits of the Data Source Controls
377
Adding the Extra Items
378
Handling the Extra Options with the SqlDataSource
379
Handling the Extra Options with the ObjectDataSource
380
Rich Data Controls
381
The GridView
382
Formatting the GridView
386
Styles
388
FormattingSpecific Values
391
GridView Row Selection
393
Using Selection to Create a MasterDetails Form
394
The SelectedIndexChanged Event
396
Using a Data Field As a Select Button
397
Sorting with the SqlDataSource
398
Sorting and Selection
400
Advanced Sorting
401
Paging the GridView
402
Automatic Paging
403
Custom Pagination with the ObjectDataSource
404
Customizing the Pager Bar
407
GridView Templates
408
Using Multiple Templates
410
Editing Templates in Visual Studio
411
Binding to a Method
412
Handling Events in a Template
413
Editing with a Template
414
The ListView
419
Grouping
422
Paging
424
The DetailsView and FormView
425
The FormView
428
Advanced Grids
429
Summaries in the GridView
430
A ParentChild View in a Single Table
431
Editing a Field Using a Lookup Table
434
Serving Images from a Database
436
Detecting Concurrency Conflicts
441
Summary
446
Caching and Asynchronous Pages
447
Output Caching
448
Caching and the Query String
449
Caching with Specific Query String Parameters
450
Custom Caching Control
451
Caching with the HttpCachePolicy Class
452
PostCache Substitution and Fragment Caching
453
Cache Profiles
455
Cache Configuration
456
Data Caching
457
Adding Items to the Cache
458
A Simple Cache Test
460
Cache Priorities
461
Caching with the Data Source Controls
462
Cache Dependencies
465
Aggregate Dependencies
466
The Item Removed Callback
467
Understanding SQL Cache Notifications
469
Cache Notifications in SQL Server 2000
470
Cache Notifications in SQL Server 2005 and SQL Server 2008
475
Custom Cache Dependencies
477
A Basic Custom Cache Dependency
478
A Custom Cache Dependency Using Message Queues
479
Asynchronous Pages
481
Creating an Asynchronous Page
482
Querying Data in an Asynchronous Page
484
Handling Errors
486
Using Caching with Asynchronous Tasks
488
Multiple Asynchronous Tasks and Timeouts
491
Summary
492
Files and Streams
493
The Directory and File Classes
494
The DirectoryInfo and FileInfo Classes
496
The DriveInfo Class
499
Working with Attributes
500
Filter Files with Wildcards
502
The Path Class
503
A File Browser
506
Reading and Writing Files with Streams
510
Text Files
512
Binary Files
513
Uploading Files
514
Making Files Safe for Multiple Users
516
Compression
521
Serialization
522
Summary
525
LINQ
527
Deferred Execution
529
How LINQ Works
530
LINQ Expressions Under the Hood
537
LINQ to DataSet
540
Typed DataSets
542
Null Values
543
Data Entity Classes
544
The DataContext
546
LINQ to SQL Queries Under the Hood
547
LINQ to SQL and Database Components
550
Selecting a Single Record or Value
552
Generating Data Classes Automatically
553
Relationships
559
Generating Methods for Stored Procedures
567
Committing Changes
569
The LinqDataSource
574
Displaying Data
575
Getting Related Data
578
Editing Data
579
Summary
582
XML
583
An Introduction to XML
584
The Advantages of XML
585
WellFormed XML
586
XML Schemas
588
StreamBased XML Processing
590
Reading XML Files
593
InMemory XML Processing
596
The XmlDocument
597
The XPathNavigator
601
The XDocument
603
Searching XML Content
608
Searching XmlDocument with XPath
611
Searching XDocument with LINQ
613
Validating XML Content
615
Validating with XDocument
617
Transforming XML Content
618
Using XslCompiledTransform
619
Using the Xml Control
621
XML Data Binding
623
Using XPath
625
Nested Grids
628
Hierarchical Binding with the TreeView
629
Using XSLT
631
Binding to XML Content from Other Sources
633
XML and the ADONET DataSet
634
Converting the DataSet to XML
635
Accessing a DataSet As XML
636
Summary
638
Building ASPNET Websites
639
Portal Frameworks
654
Partial Page Caching
657
VaryByControl
658
Sharing Cached Controls
659
Themes and Master Pages
661
Applying Stylesheet Rules
664
Themes
666
Theme Folders and Skins
667
Applying a Simple Theme
668
Handling Theme Conflicts
669
Creating Multiple Skins for the Same Control
670
Skins with Templates and Images
671
Using CSS in a Theme
673
Applying Themes Dynamically
674
Standardizing Website Layout
676
A Simple Master Page
677
A Simple Content Page
679
Default Content
680
Master Pages with Tables and CSS Layout
681
Master Pages and Relative Paths
683
Applying Master Pages Through a Configuration File
684
Advanced Master Pages
685
Dynamically Setting a Master Page
686
Nesting Master Pages
687
Summary
689
Website Navigation
691
The MultiView Control
692
The Wizard Control
696
Site Maps
703
Defining a Site Map
704
Binding to a Site Map
706
Breadcrumbs
707
Showing a Portion of the Site Map
709
The Site Map Objects
712
Adding Custom Site Map Information
714
URL Mapping
721
Security Trimming
722
The TreeView Control
724
The TreeNode
725
Populating Nodes on Demand
727
TreeView Styles
729
The Menu Control
733
Menu Styles
736
Menu Templates
737
Summary
739
Website Deployment
741
IIS Websites and Virtual Directories
742
IIS Management Console and IIS Configuration
743
Mapping Websites Virtual Directories and Files to URLs
744
Diving into the Architecture of IIS
746
Installing IIS
761
Managing Websites
767
Managing Virtual Directories and Websites with IIS 5x and IIS 60
768
Managing Application Pools in IIS 60
774
Managing Virtual Directories and Websites with IIS 70
780
Managing Application Pools in IIS 70
792
Deploying Your ASPNET Applications
794
Verifying the ASPNET Installation on IIS 5x and IIS 60
796
ASPNET SideBySide Execution on IIS 5x and IIS 60
797
ASPNET SideBySide Execution on IIS 70
799
Compilation Models in ASPNET
800
Deploying with Visual Studio
804
Visual Studio 2005 Web Deployment Projects
805
The VirtualPathProvider in ASPNET
811
Health Monitoring in ASPNET
815
Understanding the Basic Structure
816
Summary
819
Security
821
The ASPNET Security Model
823
Understanding Potential Threats
824
Understanding Gatekeepers
825
Understanding the Levels of Security
826
Authentication
827
Authorization
828
Confidentiality and Integrity
829
Internet Information Services Security
831
Security Configuration on IIS 70
834
Understanding Secure Sockets Layer
839
ASPNET Security Architecture
848
Authentication
849
Authorization
851
Membership and Roles APIs
853
Summary
854
Forms Authentication
855
Why Use Forms Authentication?
856
Why Would You Not Use Forms Authentication?
858
Why Not Implement Cookie Authentication Yourself?
859
The Forms Authentication Classes
860
Implementing Forms Authentication
861
Denying Access to Anonymous Users
865
Custom Credentials Store
872
Persistent Cookies in Forms Authentication
873
IIS 70 and Forms Authentication
874
Summary
880
Membership
881
Using the Membership API
884
Configuring Forms Authentication
885
Creating the Data Store
886
Configuring Connection String and Membership Provider
892
Creating and Authenticating Users
896
Using the Security Controls
898
The Login Control
900
The LoginStatus Control
910
The LoginView Control
911
The PasswordRecovery Control
912
The ChangePassword Control
917
The CreateUserWizard Control
918
Configuring Membership in IIS 70
922
Using the Membership API with Other Applications
924
Using the Membership Class
926
Updating Users in the Store
929
Validating Users
930
Using Membership in Windows Forms
931
Summary
933
Windows Authentication
935
Why Use Windows Authentication?
936
Why Would You Not Use Windows Authentication?
937
Mechanisms for Windows Authentication
938
Implementing Windows Authentication
944
Configuring IIS 70
946
Configuring ASPNET
948
Denying Access to Anonymous Users
951
Accessing Windows User Information
953
Impersonation
958
Impersonation in Windows 2000
959
Impersonation on Windows XP
960
Impersonation on Windows Vista
963
Impersonation and Delegation on Windows Server 2008
964
Programmatic Impersonation
966
Summary
969
Authorization and Roles
971
Authorization Rules
972
File Authorization
977
Authorization Checks in Code
978
Using the PrincipalPermission Class
979
Using the Roles API for RoleBased Authorization
981
Using the LoginView Control with Roles
987
Accessing Roles Programmatically
988
Using the Roles API with Windows Authentication
990
Protecting NonASPNET Resources in IIS 5 and 6
993
Writing a Custom HTTP Handler
994
Authorization and Roles in IIS 70
996
Authorization with ASPNET Roles in IIS 70
998
ManagingASPNET Roles with IIS 70
1001
Summary
1002
Profiles
1005
How Profiles Store Data
1006
Profiles and Authentication
1007
Using the SqlProfileProvider
1008
Configuring the Provider
1011
Defining Profile Properties
1012
Using Profile Properties
1013
Profile Serialization
1014
Profile Groups
1016
Profiles and Custom Data Types
1017
The Profiles API
1020
Anonymous Profiles
1022
Custom Profile Providers
1025
Designing the FactoredProfileProvider
1027
Coding the FactoredProfileProvider
1029
Testing the FactoredProfileProvider
1033
Summary
1036
Cryptography
1037
The NET Cryptography Namespace
1038
Understanding the NET Cryptography Classes
1042
Symmetric Encryption Algorithms
1043
Asymmetric Encryption
1044
The Abstract Encryption Classes
1045
The ICryptoTransform Interface
1046
Encrypting Sensitive Data
1047
Managing Secrets
1048
Using Symmetric Algorithms
1049
Using Asymmetric Algorithms
1054
Encrypting Sensitive Data in a Database
1057
Encrypting the Query String
1061
Wrapping the Query String
1062
Creating a Test Page
1065
Summary
1066
Custom Membership Providers
1067
Basic Steps for Creating Custom Providers
1069
Designing and Implementing the Custom Store
1070
Implementing the Provider Classes
1078
Using the Custom Provider Classes
1098
Summary
1102
Advanced User Interface
1103
Custom Server Controls
1105
Creating a BareBones Custom Control
1106
Using a Custom Control
1108
Custom Controls in the Toolbox
1109
Creating a Web Control That Supports Style Properties
1110
The Rendering Process
1114
Dealing with Different Browsers
1115
Browser Detection
1116
Browser Properties
1118
Overriding Browser Type Detection
1120
Adaptive Rendering
1121
Control State and Events
1123
Control State
1125
Postback Data and Change Events
1127
Triggering a Postback
1129
Extending Existing Web Controls
1131
End SidebarDerived Controls
1134
Template Controls
1137
Using Customized Templates
1139
Styles
1144
Summary
1146
DesignTime Support
1147
DesignTime Attributes
1148
The Properties Window
1149
Attributes and Inheritance
1153
The Toolbox Icon
1154
Web Resources
1155
Retrieving a Resource
1156
Text Substitution
1157
Code Serialization
1158
Serialization Attributes
1166
Type Editors
1168
Control Designers
1170
DesignTime HTML
1171
Smart Tags
1173
Summary
1178
Dynamic Graphics and GDI+
1179
Creating Hotspots
1180
Handling Hotspot Clicks
1181
A Custom Hotspot
1182
Drawing with GDI+
1184
Simple Drawing
1185
Image Format and Quality
1187
The Graphics Class
1188
Using a GraphicsPath
1190
Pens
1191
Brushes
1194
Embedding Dynamic Graphics in a Web Page
1195
Using the PNG Format
1196
Passing Information to Dynamic Images
1197
Custom Controls That Use GDI+
1200
Charting with GDI+
1204
Summary
1209
Portals with Web Part Pages
1211
Typical Portal Pages
1212
Basic Web Part Pages
1213
Creating the Page Design
1214
WebPartManager and WebPartZone Controls
1215
Adding Web Parts to the Page
1217
Customizing the Page
1220
Creating Web Parts
1222
Simple Web Part Tasks
1223
Developing Advanced Web Parts
1231
Web Part Editors
1240
Connecting Web Parts
1246
Custom Verbs and Web Parts
1254
User Controls and Advanced Web Parts
1255
Uploading Web Parts Dynamically
1258
Authorizing Web Parts
1264
Summary
1265
ClientSide Programming
1267
JavaScript and Ajax Techniques
1269
The HTML Document Object Model
1270
ClientSide Events
1271
Script Blocks
1273
Manipulating HTML Elements
1275
Debugging JavaScript
1276
Basic JavaScript Examples
1278
Using JavaScript to Download Images Asynchronously
1281
Rendering Script Blocks
1286
Script Injection Attacks
1287
Disabling Request Validation
1288
Custom Controls with JavaScript
1290
Rollover Buttons
1294
Frames
1297
Frame Navigation
1298
Inline Frames
1299
Understanding Ajax
1300
The XMLHttpRequest Object
1301
An Ajax Example
1303
Using Ajax with Client Callbacks
1307
Client Callbacks Under the Hood
1313
Client Callbacks in Custom Controls
1314
Summary
1318
ASPNET AJAX
1319
The Script Libraries
1320
The ScriptManager
1321
Server Callbacks
1322
Web Services in ASPNET AJAX
1323
The Web Service Proxy
1330
Placing a Web Method in a Page
1331
ASPNET AJAX Application Services
1333
ASPNET AJAX Server Controls
1339
Partial Rendering with the UpdatePanel
1340
Timed Refreshes with the Timer
1348
TimeConsuming Updates with UpdateProgress
1349
Managing Browser History
1352
Deeper into the Client Libraries
1356
ObjectOriented Programming in JavaScript
1357
The WebPage Framework
1365
Control Extenders
1371
The AutoCompleteExtender
1373
The ASPNET AJAX Control Toolkit
1376
Summary
1381
Silverlight 2
1383
Understanding Silverlight
1384
Silverlight vs Flash
1386
Silverlight System Requirements
1387
Installing the Silverlight Tools for Visual Studio
1388
Creating a Silverlight Solution
1389
Silverlight Compilation
1390
Entry Pages
1391
Creating a Silverlight Project
1396
Designing a Silverlight Page
1397
Understanding XAML
1401
Setting Properties
1402
The XAML CodeBehind
1403
Handling Events
1405
Browsing the Silverlight Class Libraries
1406
Layout
1407
The Canvas
1408
The Grid
1413
Animation
1417
Animation Basics
1418
The Storyboard Class
1419
An Interactive Animation Example
1422
Transforms
1425
Silverlight and ASPNET
1429
The MediaPlayer Control
1435
Summary
1439
Index
1441
Copyright

Other editions - View all

Common terms and phrases

About the author (2008)

Mario Szpuszta is working in the Developer and Platform Group of Microsoft, Austria. Before he started working for Microsoft, Mario was involved in several projects based on COM+ and DCOM with Visual Basic and Visual C++ as well as projects based on Java and J2SE. With beta 2 of the .NET Framework, he started developing Web applications with ASP.NET. As developer evangelist for Microsoft Austria, he is doing workshops, trainings, and proof-of-concept projects together with independent software vendors in Austria based on .NET, Web Services, and Office 2003 technologies.

Matthew MacDonald is an author, educator, and MCSD developer who has a passion for emerging technologies. He is a regular writer for developer journals such as Inside Visual Basic, ASPToday, and Hardcore Visual Studio .NET, and he's the author of several books about programming with .NET, including User Interfaces in VB .NET: Windows Forms and Custom Controls, The Book of VB .NET, and .NET Distributed Applications. In a dimly- remembered past life, he studied English literature and theoretical physics. Send e-mail with praise, condemnation, and everything in between, to p2p@prosetech.com.

Bibliographic information