مشخصات کتاب
-
Doug Lowe, Jeff Cogswell,and Ken Cox
-
2006
-
انگلیسی
-
2500
-
194
-
2
ASP.NET 2.0 All-in-One Desk Reference For Dummies®
Table of Contents
Introduction..................................................................1
About This Book...............................................................................................2
How to Use This Book .....................................................................................3
How This Book Is Organized...........................................................................3
Book I: ASP.NET Basics ..........................................................................3
Book II: Web Controls.............................................................................3
Book III: HTML ........................................................................................3
Book IV: C# ..............................................................................................4
Book V: Visual Basic...............................................................................4
Book VI: Database Programming..........................................................4
Book VII: Using the .NET Framework ...................................................4
Book VIII: Advanced ASP.NET Programming.......................................4
Icons Used in This Book..................................................................................4
Where to Go from Here....................................................................................5
Book I: ASP.NET Basics .................................................7
Chapter 1: Welcome to ASP.NET Programming . . . . . . . . . . . . . . . . . . . .9
What Is ASP.NET, and Why Is It So Great? .....................................................9
Windows and IIS dependence .............................................................10
Object orientation ................................................................................11
Choice of languages .............................................................................11
Visual Studio .........................................................................................12
Understanding Web Servers and Browsers ................................................12
Understanding Static Web Pages..................................................................13
Understanding Dynamic Web Pages ............................................................14
Looking at a Simple ASP.NET Application...................................................15
The .aspx (Markup) File for the Simple Calculator Application ..............17
The Code-Behind File of the Simple Calculator Application ....................18
Chapter 2: Installing Visual Studio Web Developer 2005
Express Edition or Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Looking at Visual Studio 2005 Editions .......................................................21
Considering Visual Web Developer 2005 Express Edition ........................22
Installing Visual Web Developer 2005 Express Edition .............................22
Registering Visual Web Developer 2005 Express Edition..........................27
Installing Visual Studio 2005 .........................................................................30
Chapter 3: Creating Your First ASP.NET 2.0 Application . . . . . . . . . . . .35
Understanding Visual Studio Projects.........................................................35
Creating a New Web Site................................................................................36
Using the Solution Explorer ..........................................................................39
Working with Controls...................................................................................40
Setting Properties ..........................................................................................44
Setting the Page Title .....................................................................................46
Looking at the Source Code..........................................................................47
Adding Some Code.........................................................................................48
Running the Application................................................................................51
Chapter 4: Understanding Postback, Events, and Code-Behind . . . . .53
Understanding Postback...............................................................................53
Using the IsPostBack Variable ......................................................................54
Understanding Events ...................................................................................55
Using the Handles Clause in Visual Basic ...................................................56
Designating an Event Handler in C# ............................................................58
Using C#’s Auto Event Wireup......................................................................58
Understanding Code-Behind.........................................................................59
Using Single-File Pages ..................................................................................60
Chapter 5: Creating Multipage Applications . . . . . . . . . . . . . . . . . . . . .63
Understanding the Basics of a Multipage Application ..............................63
Adding Pages ..................................................................................................66
Redirecting to Another Page.........................................................................67
Adding Classes ...............................................................................................68
Using Session State ........................................................................................71
Looking into Data Binding.............................................................................74
Using Master Pages........................................................................................75
Creating a Master Page ........................................................................75
Creating a content page.......................................................................78
The C# Version of the Shopping Cart Application .....................................79
The VB.NET Version of the Shopping Cart Application ............................83
Chapter 6: Testing and Debugging Your ASP.NET Applications . . . . .87
Creating a Simple Calculator Application ...................................................87
Running an ASP.NET Application .................................................................89
Dealing with Errors ........................................................................................91
Working in Break Mode .................................................................................93
Displaying Variable Data ...............................................................................93
Stepping Through a Program........................................................................95
Setting Breakpoints........................................................................................96
Using Response.Write for Debugging ..........................................................97
Book II: Web Controls..................................................99
Chapter 1: Using Basic Web Server Controls . . . . . . . . . . . . . . . . . . . .101
Using Label Controls....................................................................................101
Using TextBox Controls...............................................................................103
Using Button Controls .................................................................................105
Using CheckBox Controls............................................................................107
Checking the Checked property.......................................................108
Another way to check the Checked property.................................109
Using RadioButton Controls .......................................................................111
Using Image Controls...................................................................................112
Chapter 2: Using Validation Controls . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Validating the Hard Way ..............................................................................115
Validation Controls to the Rescue!.............................................................117
Using the RequiredFieldValidator Control ................................................118
Using the CompareValidator Control.........................................................120
Using the RangeValidator Control..............................................................122
Using the RegularExpressionValidator......................................................123
Using a CustomValidator Control...............................................................125
Using the ValidationSummary Control ......................................................126
Using the CausesValidation and ValidationGroup Properties ................128
Chapter 3: Using List Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
Using the CheckBoxList Control ................................................................131
Creating columns................................................................................133
Aligning text with check boxes.........................................................134
Spacing things out..............................................................................135
Working with ListItem Elements.................................................................135
Using the Text property.....................................................................135
Using the Value property...................................................................136
Determining which items are selected ............................................136
Using the Collection Editor dialog box............................................137
Toiling with the RadioButtonList Control .................................................138
Utilizing ListBox Controls ...........................................................................139
Employing DropDownList Controls ...........................................................141
Accomplishing More with List Items in Code...........................................143
Adding an item to a list......................................................................143
Clearing the list...................................................................................143
Selecting and deselecting items .......................................................144
Finding an item ...................................................................................144
Chapter 4: Using Advanced Web Server Controls . . . . . . . . . . . . . . . .147
Using the MultiView Control.......................................................................147
Utilizing the Wizard Control .......................................................................152
Creating steps in Visual Studio.........................................................154
Using Wizard events...........................................................................156
Looking at the code for a Wizard control........................................157
Working with the Calendar Control ...........................................................160
Making Use of the FileUpload Control.......................................................163
Chapter 5: Working with User Controls . . . . . . . . . . . . . . . . . . . . . . . . .165
Introducing User Controls...........................................................................165
Creating a User Control ...............................................................................167
Adding a User Control to a Page ................................................................169
Adding Properties to a User Control .........................................................170
Putting User-Control Properties to Work..................................................173
Book III: HTML .........................................................175
Chapter 1: HTML Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177
XHTML Rulez! ...............................................................................................177
XHTML and the W3C..........................................................................178
The strict upbringing of XHTML.......................................................178
Making your HTML well-formed .......................................................179
More XHTML requirements...............................................................180
Taking characters as an entity..........................................................181
VWDE’s Support for XHTML .......................................................................181
A solemn DOCTYPE declaration.......................................................181
Validity spy..........................................................................................182
Letting VWDE fix old code.................................................................185
You can go your own way..................................................................189
Editing Code in Source View.......................................................................190
Preserving source code .....................................................................191
Cleaning up source code ...................................................................192
Using the Tag Navigator ....................................................................192
Collapsing and outlining....................................................................193
No Comment! ......................................................................................193
Editing Pages in Design View......................................................................194
Establishing a position in Design view ............................................194
Positioning a Single Control ..............................................................197
Viewing an HTML document’s structure.........................................197
Manipulating the DOM.......................................................................198
Formatting Text ............................................................................................198
The Formatting toolbar .....................................................................199
The Format menu ...............................................................................199
Properties pages.................................................................................200
Chapter 2: Creating Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
Some Basic Table Talk .................................................................................202
Adding headers, a caption, and a summary ...................................202
Grouping and spanning columns and rows.....................................205
Creating Tables in the Designers................................................................207
The Toolbox table ..............................................................................207
The table designer..............................................................................208
The ASP.NET table tool ......................................................................209
Creating Tables Programmatically.............................................................212
Building a table by using the Repeater control ..............................212
Building an ASP.NET table from scratch..........................................215
Creating a Table-Based Framework ...........................................................217
Chapter 3: Working with Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .221
Understanding Forms ..................................................................................221
Creating a Form ............................................................................................223
A call to action — sent by post ........................................................223
Staying on target.................................................................................224
Your special events form...................................................................224
Working with Text Boxes.............................................................................225
Creating text fields with <input> ......................................................226
Creating a password text box ...........................................................227
Super-sizing a text field......................................................................227
Working with Buttons ..................................................................................229
Creating a submit button...................................................................229
Creating a reset button ......................................................................230
Creating an ordinary button .............................................................230
Creating an image button ..................................................................230
Creating submit, reset, and ordinary buttons another way .........231
Working with Check Boxes and Radio Buttons ........................................232
Creating a check box..........................................................................232
Creating a radio button......................................................................232
Using Drop-Down Lists and List Boxes......................................................233
Creating a drop-down list ..................................................................233
Creating a list box...............................................................................234
Creating a hierarchical drop-down list and list box.......................235
Checking Form Submissions with ASP.NET ..............................................237
Setting the Tab Order ..................................................................................238
Chapter 4: Using Styles and Style Sheets . . . . . . . . . . . . . . . . . . . . . . .241
Understanding Styles...................................................................................241
Cascading Style Sheets ......................................................................242
Style selectors and other syntax ......................................................244
Working with Styles in Visual Studio 2005 and
Visual Web Developer ..............................................................................246
Setting the CSS validation schema ...................................................246
Creating inline styles in Design view ...............................................248
Creating inline styles in Source view ...............................................252
Building external style sheets...........................................................254
Creating a class with style.................................................................256
Using Span and Div for Styles and Positions ............................................257
Highlighting text with <span> ...........................................................258
Creating a layer with <div>................................................................259
Showing and hiding the <div>...........................................................260
Creating and Applying Styles in Code .......................................................261
Applying inline styles in code...........................................................261
Inserting embedded styles with code..............................................262
Letting users choose their style sheet ............................................263
Chapter 5: Using Client-Side Script . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
Sampling Client-Side Script on Microsoft.com .........................................267
Compensating for browser differences ...........................................268
Embedding multimedia content .......................................................268
Tracking page views and statistics ..................................................269
Making the page interactive..............................................................270
Creating random content and surveys............................................270
Embedding Script in an ASP.NET Page ......................................................271
Embedding a block of script .............................................................272
Inserting a hidden field into a page..................................................274
Embedding code so that it executes on startup ............................275
Embedding code to catch a page submit ........................................277
Capturing the hidden field ................................................................278
Referencing external scripts .............................................................279
Storing an array of values in a page.................................................280
Using Client-Side Scripts in ASP.NET .........................................................281
Identifying page elements by using script ......................................282
Using alert( ) to stop users cold.......................................................284
confirm( ) a drastic action.................................................................285
Creating a rollover effect ...................................................................286
Client-Side Script and Validation Controls................................................287
How Auto-Postback Uses Client-Side Script .............................................289
Using Client-Side Callbacks.........................................................................291
Creating the Web page interface ......................................................292
Preparing the JavaScript ...................................................................293
Building the server-side algorithm ..................................................294
Implementing ICallbackEventHandler .............................................294
Generating the callback code ...........................................................296
Making the callback call ....................................................................297
Callback source code.........................................................................298
Book IV: C# ..............................................................301
Chapter 1: C# Programming Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . .303
Dealing with Keywords................................................................................303
Working with Statements ............................................................................304
Types of statements...........................................................................304
White space.........................................................................................305
Working with Blocks ....................................................................................306
Creating Identifiers ......................................................................................307
Crafting Comments ......................................................................................307
Single-line comments .........................................................................307
Delimited comments ..........................................................................308
Introducing Object-Oriented Programming..............................................308
Understanding classes and objects .................................................308
Coding a class .....................................................................................309
Creating an object from a class ........................................................310
Using .NET Framework Classes..................................................................311
Declaring Variables ......................................................................................312
Declaring two or more variables in one statement........................313
Declaring instance variables.............................................................313
Declaring local variables ...................................................................314
Initializing Variables.....................................................................................315
Initializing variables with assignment statements .........................315
Initializing variables with initializers ...............................................315
Working with Built-in Data Types...............................................................316
Integer (int) types ..............................................................................317
Floating-point types ...........................................................................318
The decimal type................................................................................319
The char type......................................................................................319
The boolean type................................................................................320
Working with Strings....................................................................................320
Declaring and initializing strings......................................................321
Combining strings ..............................................................................321
Converting strings to primitives ......................................................322
Working with Arithmetic Operators ..........................................................323
Dividing Integers ..........................................................................................325
Combining Operators ..................................................................................326
Using the Unary Plus and Minus Operators .............................................327
Using Increment and Decrement Operators.............................................328
Using the Assignment Operator.................................................................329
Using Compound Assignment Operators .................................................331
Chapter 2: Doing Things Conditionally in C# . . . . . . . . . . . . . . . . . . . .333
Using Simple boolean Expressions ............................................................333
Using if Statements ......................................................................................335
Simple if statements...........................................................................335
if-else statements................................................................................338
Nested if statements ..........................................................................339
else-if statements................................................................................341
Mr. Spock’s Favorite Operators (the Logical Ones, of Course)..............343
Using the ! operator ...........................................................................344
Using the & and && operators..........................................................345
Using the | and || operators............................................................346
Pulling the Ol’ Switch-er-oo ........................................................................347
Creating else-if monstrosities ...........................................................347
Using the switch statement...............................................................348
A better version of the Voter-Error-Code Decoder program ........349
Chapter 3: Going Around in Circles (Or, Looping in C#) . . . . . . . . . . .351
Your Basic while Loop .................................................................................351
The while statement ..........................................................................352
A counting loop ..................................................................................352
Breaking Out of a Loop................................................................................353
Looping Forever ...........................................................................................354
Using the continue Statement ....................................................................355
Understanding do-while Loops ..................................................................356
The Famous for Loop...................................................................................358
The formal format of the for loop ....................................................358
Scoping out the counter variable.....................................................360
Counting even numbers ....................................................................361
Counting backward ............................................................................361
for loops without bodies ...................................................................362
Ganging up your expressions ...........................................................362
Omitting expressions.........................................................................363
Breaking and continuing your for loops..........................................364
Nesting Your Loops......................................................................................365
Chapter 4: Using Methods and Exceptions . . . . . . . . . . . . . . . . . . . . . .367
The Basics of Making Methods...................................................................367
A Simple Example.........................................................................................368
Methods that Return Values .......................................................................369
Declaring the method’s return type.................................................370
Using the return statement to return the value..............................370
Using Methods that Take Parameters .......................................................371
Declaring parameters ........................................................................371
Understanding pass-by-value............................................................372
Understanding Exceptions..........................................................................373
Catching Exceptions ....................................................................................374
Catching Different Exception Types ..........................................................375
Using the Exception Message .....................................................................376
Using a finally Block.....................................................................................376
Chapter 5: Getting into Object-Oriented Programming . . . . . . . . . . .377
What Is Object-Oriented Programming? ...................................................377
Understanding Objects................................................................................379
Objects have identity.........................................................................379
Objects have type...............................................................................380
Objects have state..............................................................................381
Objects have behavior.......................................................................381
The Life Cycle of an Object.........................................................................382
Working with Related Classes.....................................................................383
Inheritance ..........................................................................................383
Interfaces.............................................................................................384
Declaring a Class ..........................................................................................385
Picking class names ...........................................................................385
What goes in the class body .............................................................385
Using Fields...................................................................................................386
Creating Properties......................................................................................387
Using Methods..............................................................................................389
Creating Constructors .................................................................................390
Basic constructors .............................................................................391
Default constructors ..........................................................................392
Using this.......................................................................................................392
Working with Static Members.....................................................................393
Working with static fields or properties..........................................394
Using static methods .........................................................................394
Chapter 6: Working with Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . .397
Understanding Inheritance .........................................................................397
A real-world explanation ...................................................................398
A fun explanation ...............................................................................399
A business-world explanation...........................................................399
Inheritance hierarchies......................................................................400
Creating Derived Classes ............................................................................400
Overriding Methods.....................................................................................401
Protecting Your Members ...........................................................................402
Using this and base in Your Derived Classes............................................403
Inheritance and Constructors ....................................................................404
Casting Up and Down ..................................................................................405
Determining an Object’s Type: The is Operator ......................................406
Poly What? ....................................................................................................407
Book V: Visual Basic .................................................409
Chapter 1: Mastering the Basics of Visual Basic . . . . . . . . . . . . . . . .411
Looking at Classes, Structures, and Modules...........................................411
Working with Source Files...........................................................................412
Creating Sub Procedures.............................................................................413
Working with Statements ............................................................................414
Creating Identifiers ......................................................................................415
Adding Comments to Your Code................................................................416
Declaring Variables ......................................................................................416
Working with Data Types ............................................................................417
Integer types .......................................................................................418
Floating-point types ...........................................................................419
The decimal type................................................................................419
The char type......................................................................................420
The Boolean type ...............................................................................420
Working with Strings....................................................................................420
Declaring and initializing strings......................................................420
Combining strings ..............................................................................421
Converting strings..............................................................................421
Working with Arithmetic Operators ..........................................................422
Combining Operators ..................................................................................423
Using Assignment Statements ....................................................................424
Using Assignment Operators......................................................................425
Chapter 2: Controlling Your Programs . . . . . . . . . . . . . . . . . . . . . . . . . .427
Using If Statements ......................................................................................427
The basic If statement .......................................................................428
The single-line If..................................................................................429
The Else clause ...................................................................................429
Nesting If statements .........................................................................430
The ElseIf structure............................................................................430
Using Conditional Expressions...................................................................433
Getting Logical..............................................................................................434
Using the Not operator ......................................................................435
Working with the And operator........................................................435
Utilizing the AndAlso operator.........................................................435
Using the Or and OrElse operators..................................................436
Using the Select Case Statement ................................................................436
Working with For/Next Loops.....................................................................438
Using While loops...............................................................................439
Utilizing Do loops ...............................................................................440
Exiting a loop ......................................................................................441
Nesting your loops .............................................................................441
Chapter 3: Working With Procedures, Exceptions, and Arrays . . . .443
Using Sub Procedures..................................................................................444
Working with Functions...............................................................................445
Getting Finicky about Parameters..............................................................446
Understanding Exceptions..........................................................................448
Catching exceptions...........................................................................448
Using a Finally block ..........................................................................450
Using Arrays .................................................................................................450
Creating an array ................................................................................451
Initializing an array.............................................................................451
Using For loops with arrays ..............................................................452
Using two-dimensional arrays ..........................................................452
Chapter 4: Exploring Object-Oriented Programming . . . . . . . . . . . . .455
Introducing Object-Oriented Programming..............................................455
Objects have identity.........................................................................456
Objects have type...............................................................................456
Objects have state..............................................................................456
Objects have behavior.......................................................................457
Creating Objects from Classes ...................................................................458
Declaring Classes .........................................................................................458
Using fields ..........................................................................................459
Creating properties ............................................................................460
Using methods ....................................................................................462
Creating constructors........................................................................463
Using Shared Members................................................................................464
Chapter 5: Demystifying Inheritance in VB.NET . . . . . . . . . . . . . . . . .467
Understanding Inheritance .........................................................................467
Understanding Inheritance Hierarchies ....................................................469
Creating a Derived Class .............................................................................469
Overriding Methods.....................................................................................470
Using Protected Members...........................................................................471
Using the MyBase Keyword ........................................................................472
Using Casting with Inheritance...................................................................472
Determining an Object’s Type ....................................................................474
Confronting Polymorphism ........................................................................474
Book VI: Database Programming ................................477
Chapter 1: Accessing Data with ADO.NET . . . . . . . . . . . . . . . . . . . . . .479
Understanding the Basics of Relational Databases .................................480
Gathering data into tables.................................................................480
Organizing with rows and columns..................................................481
Distinguishing data with primary keys and foreign keys ..............481
Indexing your data for fast retrieval ................................................484
Working with Databases Using SQL ...........................................................485
Creating a table with CREATE TABLE...............................................486
Deleting a table with DROP TABLE...................................................489
Getting data with SELECT..................................................................490
Selecting only specific rows with the WHERE clause ....................491
Adding data with INSERT ..................................................................491
Modifying data with UPDATE............................................................492
Removing data with DELETE ............................................................493
Piecing Together SQL Statements..............................................................494
Connecting to Data with ADO.NET ............................................................495
Issuing Database Commands......................................................................498
Calling statements that return no data............................................498
Calling a stored procedure................................................................499
Calling statements that return one data item.................................500
Displaying Data on a Web Page ..................................................................501
Retrieving Data from a Table ......................................................................503
Adding Security to Your SQL Statements — Read This!..........................504
Chapter 2: Displaying and Editing Data for the Web . . . . . . . . . . . . . .507
Writing Data to a Page with a Label ...........................................................507
Binding to Data.............................................................................................509
Creating a data source.......................................................................509
Using a data source............................................................................516
Repeating Through a Result Set .................................................................518
Setting server control properties in a Repeater control ...............519
Adding some style to the Repeater control ....................................520
Altering the look of the Repeater control’s rows ...........................521
Creating a Data-Entry Page .........................................................................523
Chapter 3: Displaying and Editing with the GridView Control . . . . .529
Setting Up the AdventureWorks Database................................................529
Creating a GridView Control .......................................................................530
Formatting the Display ................................................................................532
Editing and Deleting Data with a GridView...............................................534
Sorting and Paging the Data in Your Grid .................................................540
Customizing the Columns in a Grid ...........................................................542
Specifying headers .............................................................................546
Displaying formatted text with the BoundField type.....................546
Displaying images from a URL with the ImageField type ..............547
Chapter 4: Displaying and Editing Detail Data . . . . . . . . . . . . . . . . . . .551
Introducing the DetailsView and FormView Controls .............................552
Displaying a Record with a DetailsView Control......................................552
Moving through data by paging........................................................556
Using GridView and DetailsView controls together.......................556
Editing Data with a DetailsView........................................................560
Searching and displaying details......................................................564
Displaying Record Details with a FormView Control...............................566
Using GridView and FormView controls together..........................567
Editing data with a FormView...........................................................569
Chapter 5: Advanced Data Retrieval . . . . . . . . . . . . . . . . . . . . . . . . . . .575
Ditching the Eval Method............................................................................575
Binding to Different Kinds of Data .............................................................578
Skipping the SQLDataSource.............................................................578
Binding SqlDataAdapter results to controls ...................................580
Attaching arrays to data-bound controls ........................................581
Advanced Usage of Repeater Controls .....................................................584
Creating a table around a Repeater .................................................584
Handling Repeater events .................................................................586
Chapter 6: Reading XML and Generic Data . . . . . . . . . . . . . . . . . . . . .591
Putting Together Some XML .......................................................................591
Transforming XML into a Formatted Table...............................................594
Displaying XML in a TreeView Control......................................................600
Accessing Generic Data with an ObjectDataSource Control ..................604
Book VII: Using the .NET Framework ..........................609
Chapter 1: Handling Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .611
Formatting Strings........................................................................................611
Supplying parameters other than strings .......................................612
Formatting the numeric parameters................................................613
Formatting dates and times ..............................................................615
Customizing data formats .................................................................616
Handling Special HTML Characters in Strings..........................................619
Splitting and Combining Strings.................................................................620
Splitting strings...................................................................................621
Combining strings ..............................................................................622
Converting to Strings with the ToString Method .....................................623
Converting Strings to Numbers..................................................................625
Piecing Together Strings with a StringBuilder..........................................626
Chapter 2: Manipulating Dates and Times . . . . . . . . . . . . . . . . . . . . . .629
Getting the Current Date and Time............................................................629
Reading the Components of a DateTime Structure .................................630
Streaming a DateTime Structure ................................................................632
Handling Local Times Versus Universal Times ........................................634
Calculating with Dates.................................................................................637
Parsing a Date-Time String..........................................................................642
Chapter 3: Storing Objects in Specialized Collections . . . . . . . . . . .647
Iterating Through a Collection ...................................................................647
Using the ArrayList Class............................................................................651
Sorting a list ........................................................................................652
Comparing different types ................................................................655
Using the Hashtable Class...........................................................................657
Using the Stack Class...................................................................................660
Using the Queue Class.................................................................................662
Collecting Strings .........................................................................................664
Using the StringCollection class.......................................................664
Using the StringDictionary class ......................................................664
Ordering Associations with the OrderedDictionary................................665
Chapter 4: Building Strongly Typed Collections
with Generic Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .667
Understanding the Name Game .................................................................668
Using the Generic List Class .......................................................................668
Working with the Generic LinkedList Class ..............................................670
Employing the Generic Dictionary Class ..................................................676
Using the Generic SortedDictionary Class................................................679
Using the Generic Stack Class ....................................................................679
Working with the Generic Queue Class .....................................................681
Book VIII: Advanced ASP.NET Programming ...............683
Chapter 1: Security: Using Login Controls . . . . . . . . . . . . . . . . . . . . . .685
Understanding Authentication and Authorization ..................................685
Implementing Forms Authentication.........................................................686
Creating the Web site .........................................................................687
Adding pages to the resto Web site .................................................688
Implementing membership features................................................689
Creating users .....................................................................................692
Creating access rules for the pages .................................................693
Using the Login control .....................................................................697
Using the LoginName control ...........................................................700
Using the LoginStatus control...........................................................701
Using the LoginView control.............................................................702
Using the PasswordRecovery control .............................................703
Using the ChangePassword control .................................................705
Assigning users to roles.....................................................................706
Giving permissions to a role .............................................................707
Peering into the Application Programming Interface (API)....................709
Using the Membership and MembershipUser classes ..................709
Using the Roles class .........................................................................711
Chapter 2: Using Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .715
Understanding Profiles................................................................................715
Enabling Anonymous User Profiles............................................................716
Deciding what data to store..............................................................717
Enabling profiles in the configuration file .......................................717
Generating the database ...................................................................719
Exploring the profile database..........................................................719
Building the Profile-Based Web Page.........................................................721
Adding control markup to the page .................................................721
Adding code to retrieve profile values ............................................723
Displaying the date and time in the chosen language ...................723
Storing the language choice in the profile ......................................724
Storing the image choice in the profile............................................724
Storing the background color in the profile....................................725
Testing the profile properties ...........................................................725
Using Profiles with Authenticated Users ..................................................726
Viewing the list of profiles.................................................................727
Maintaining the Profiles Database .............................................................729
Deleting inactive profiles...................................................................730
Deleting a specific profile ..................................................................731
Using a Custom Profile Provider ................................................................732
Obtaining the Access provider.........................................................733
Building the Access provider............................................................733
Chapter 3: Site Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .739
Understanding Site Navigation...................................................................739
Using a Web.sitemap File.............................................................................740
Creating the Web.sitemap file ...........................................................740
Adding data to the sitemap file ........................................................742
Using the SiteMapDataSource control .............................................743
Using the TreeView Control ........................................................................744
Creating a TreeView in Design view .................................................745
Creating a TreeView programmatically ...........................................750
Creating a TreeView from a sitemap ................................................754
Using the Menu Control...............................................................................756
Creating a Menu in Design view........................................................756
Creating a Menu programmatically..................................................760
Creating a Menu from a sitemap.......................................................764
Using the SiteMapPath Control ..................................................................764
Creating a SiteMapPath in Design view ...........................................765
Creating a SiteMapPath control programmatically........................766
Using an image as a path separator.................................................768
Chapter 4: Working with Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .771
Understanding Site Themes........................................................................771
Creating an Opening Theme .......................................................................772
Adding the App_Themes folder........................................................773
Adding a .skin file ...............................................................................774
Creating rough skin ............................................................................775
Refining the skin properties..............................................................776
Testing the skin...................................................................................776
Letting Users Choose a Theme...................................................................777
The Normal theme .............................................................................778
The Accountant theme ......................................................................779
A theme for lawyers ...........................................................................779
Applying a Theme Programmatically ........................................................780
Storing the Theme in a Profile ....................................................................782
Dos and Don’ts for Themes ........................................................................783
Shifting Definitions to Styles.......................................................................783
Overriding Themes and Who’s the Boss...................................................784
Theme vs StyleSheetTheme..............................................................784
Implementing a global theme ...........................................................786
Exempting a page from theming.......................................................787
Exempting a control from theming ..................................................787
Where to Get Themes ..................................................................................787
Chapter 5: Building Portals with Web Parts . . . . . . . . . . . . . . . . . . . . .789
Understanding Portals.................................................................................789
An Example Web Portal ...............................................................................790
Security for your custom page .........................................................791
Personalization of your page ............................................................791
Choice of language .............................................................................792
Choice of content ...............................................................................792
Custom layout.....................................................................................794
Show and hide content ......................................................................794
Themes ................................................................................................794
Understanding the Parts of Web Parts ......................................................795
Web parts infrastructure elements ..................................................795
Personalization, logins, and Web parts ...........................................796
Creating a Simple Web Part.........................................................................796
Faking a login for development purposes.......................................796
Create a page and Web-part zones...................................................798
Add some Web-part content .............................................................800
Test the Web-part page......................................................................801
Oops, I closed the Web part and it’s gone!......................................804
Letting the User Move Web Parts Around ................................................805
Adding code to support Web-part Design mode ............................805
Playing with Web-part Design mode ................................................807
Connecting Web Parts Together.................................................................809
Creating a data consumer Web part ................................................809
Creating a data provider Web part...................................................811
Creating a connectable data provider .............................................812
Creating a data exchange interface..................................................813
Getting Web parts on the same page ...............................................814
Connecting Web Parts Dynamically...........................................................820
Web parts à la mode ..........................................................................821
Creating a mode selector...................................................................821
Adding a ConnectionsZone interface...............................................823
Making connections ...........................................................................824
Breaking connections ........................................................................826
Using the Editor Controls............................................................................827
Adding EditorZone and AppearanceEditorPart controls..............827
Changing a Web part’s appearance..................................................828
Using other editor parts ....................................................................829
Letting Users Select Their Web Parts ........................................................829
Adding CatalogZone and DeclarativeCatalogPart controls ..........830
Selecting a part from the catalog .....................................................831
Chapter 6: Creating and Consuming Web Services . . . . . . . . . . . . . .833
Understanding Web Services......................................................................834
A supercomputer scenario................................................................834
A super solution .................................................................................834
The black box .....................................................................................835
Exposing an API ..................................................................................835
Not just HTTP .....................................................................................836
Expanding demands...........................................................................836
It can be done .....................................................................................836
Creating a Web Service................................................................................837
Add a Web service to your project ..................................................837
Analyze this! ........................................................................................838
Replace the default namespace........................................................840
Add the RomanNumerals function...................................................841
A quick test of the Web service ........................................................843
Other valuable information...............................................................844
Providing information to clients.......................................................846
Consuming a Web Service...........................................................................846
Using the service in a Web page and project..................................847
Using the service from Windows Forms..........................................852
Using the service from VBScript ......................................................853
Pick a platform....................................................................................855
Serving a Larger Helping of Data................................................................856
Preparing the RockHits Web service ...............................................856
Securing a Web Service ...............................................................................860
Index........................................................................863
کتاب آموزش ASP.NET 3.5 در C # 2008از تازه کار تا حرفه ایC # 2008
نویسنده: Matthew MacDonald
زبان: انگلیسی
کتاب آموزش Web Development، سیلورلایت و ASP.NET AJAX از تازه کار تا حرفه ای
نویسنده: Laurence Moroney
زبان: انگلیسی