Tải bản đầy đủ (.pdf) (10 trang)

Professional ASP.NET 3.5 in C# and Visual Basic Part 2 ppsx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (55.91 KB, 10 trang )

Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xiv
Contents
ListView 350
FormView 360
Other Databound Controls 365
DropDownList, ListBox, RadioButtonList, and CheckBoxList 365
TreeView 366
Ad Rotator 366
Menu 367
Inline Data-Binding Syntax 367
Data-Binding Syntax Changes 368
XML Data Binding 369
Expressions and Expression Builders 369
Summary 375
Chapter 8: Data Management with ADO.NET 377
Basic ADO.NET Features 378
Common ADO.NET Tasks 378
Basic ADO.NET Namespaces and Classes 383
Using the Connection Object 384
Using the Command Object 386
Using the DataReader Object 387
Using Data Adapter 389
Using Parameters 392
Understanding DataSet and DataTable 395
Using Oracle as Your Database with ASP.NET 3.5 400
The DataList Server Control 403
Looking at the Available Templates 403
Working with ItemTemplate 404
Working with Other Layout Templates 407
Working with Multiple Columns 409
The ListView Server Control 410


Looking at the Available Templates 410
Using the Templates 411
Creating the Layout Template 412
Creating the ItemTemplate 414
Creating the EditItemTemplate 415
Creating the EmptyItemTemplate 415
Creating the InsertItemTemplate 416
The Results 416
Using Visual Studio for ADO.NET Tasks 419
Creating a Connection to the Data Source 419
Working with a Dataset Designer 422
Using the CustomerOrders DataSet 427
xiv
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xv
Contents
Asynchronous Command Execution 432
Asynchronous Connections 454
Summary 454
Chapter 9: Querying with LINQ 455
LINQ to Objects 455
Traditional Query Methods 455
Replacing Traditional Queries with LINQ 464
Data Grouping 472
Other LINQ Operators 473
LINQ Joins 473
Paging Using LINQ 475
LINQ to XML 476
Joining XML Data 479
LINQ to SQL 481
Insert, Update, and Delete Queries through LINQ 490

Extending LINQ 494
Summary 495
Chapter 10: Working with XML and LINQ to XML 497
The Basics of XML 498
The XML InfoSet 500
XSD–XML Schema Definition 501
Editing XML and XML Schema in Visual Studio 2008 503
XmlReader and XmlWriter 506
Using XDocument Rather Than XmlReader 508
Using Schema with XmlTextReader 509
Validating Against a Schema Using an XDocument 511
Including NameTable Optimization 513
Retrieving .NET CLR Types from XML 515
ReadSubtree and XmlSerialization 517
Creating CLR Objects from XML with LINQ to XML 518
Creating XML with XmlWriter 519
Creating XML with LINQ for XML 522
Improvements for XmlReader and XmlWriter in 2.0 524
XmlDocument and XPathDocument 525
Problems with the DOM 525
XPath, the XPathDocument, and XmlDocument 525
DataSets 530
Persisting DataSets to XML 530
XmlDataDocument 531
xv
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xvi
Contents
The XmlDataSource Control 533
XSLT 537
XslCompiledTransform 539

XSLT Debugging 543
Databases and XML 544
FOR XML AUTO 545
SQL Server 2005 and the XML Data Type 549
Summary 556
Chapter 11: IIS7 557
Modular Architecture of IIS7 557
IIS-WebServer 558
IIS-WebServerManagementTools 561
IIS-FTPPublishingService 562
Extensible Architecture of IIS7 562
IIS7 and ASP.NET Integrated Pipeline 562
Building a Customized Web Server 564
Update Dependencies 565
Installing IIS7 on Windows Vista 565
Installing IIS7 on Windows Server 2008 565
Command-Line Setup Options 567
Unattended Setup Option 568
Upgrade 569
Internet Information Services (IIS) Manager 569
Application Pools 570
Web Sites 575
Hierarchical Configuration 577
Delegation 581
Moving an Application from IIS6 to IIS7 584
Summary 586
Chapter 12: Introduction to the Provider Model 587
Understanding the Provider 588
The Provider Model in ASP.NET 3.5 589
Setting Up Your Provider to Work with Microsoft SQL Server 7.0, 2000, 2005, or 2008 591

Membership Providers 598
Role Providers 602
The Personalization Provider 606
The SiteMap Provider 608
xvi
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xvii
Contents
SessionState Providers 609
Web Event Providers 612
Configuration Providers 620
The WebParts Provider 623
Configuring Providers 625
Summary 626
Chapter 13: Extending the Provider Model 627
Providers Are One Tier in a Larger Architecture 627
Modifying Through Attribute-Based Programming 628
Simpler Password Structures Through the SqlMembershipProvider 629
Stronger Password Structures Through the SqlMembershipProvider 632
Examining ProviderBase 633
Building Your Own Providers 635
Creating the CustomProviders Application 635
Constructing the Class Skeleton Required 636
Creating the XML User Data Store 640
Defining the Provider Instance in the web.config File 641
Not Implementing Methods and Properties of the MembershipProvider Class 642
Implementing Methods and Properties of the MembershipProvider Class 643
Using the XmlMembershipProvider for User Login 651
Extending Pre-Existing Providers 652
Limiting Role Capabilities with a New LimitedSqlRoleProvider Provider 652
Using the New LimitedSqlRoleProvider Provider 656

Summary 660
Chapter 14: Site Navigation 661
XML-Based Site Maps 662
SiteMapPath Server Control 664
The PathSeparator Property 666
The PathDirection Property 668
The ParentLevelsDisplayed Property 669
The ShowToolTips Property 669
The SiteMapPath Control’s Child Elements 670
TreeView Server Control 670
Identifying the TreeView Control’s Built-In Styles 674
Examining the Parts of the TreeView Control 676
Binding the TreeView Control to an XML File 676
Selecting Multiple Options in a TreeView 679
xvii
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xviii
Contents
Specifying Custom Icons in the TreeView Control 683
Specifying Lines Used to Connect Nodes 685
Working with the TreeView Control Programmatically 687
Menu Server Control 693
Applying Different Styles to the Menu Control 694
Menu Events 700
Binding the Menu Control to an XML File 701
SiteMap Data Provider 703
ShowStartingNode 703
StartFromCurrentNode 704
StartingNodeOffset 705
StartingNodeUrl 706
SiteMap API 706

URL Mapping 709
Sitemap Localization 710
Structuring the Web.sitemap File for Localization 710
Making Modifications to the Web.config File 711
Creating Assembly Resource (.resx) Files 712
Testing the Results 712
Security Trimming 714
Setting Up Role Management for Administrators 715
Setting Up the Administrators’ Section 716
Enabling Security Trimming 718
Nesting SiteMap Files 720
Summary 722
Chapter 15: Personalization 723
The Personalization Model 723
Creating Personalization Properties 725
Adding a Simple Personalization Property 725
Using Personalization Properties 726
Adding a Group of Personalization Properties 730
Using Grouped Personalization Properties 731
Defining Types for Personalization Properties 731
Using Custom Types 732
Providing Default Values 735
Making Personalization Properties Read-Only 735
Anonymous Personalization 735
Enabling Anonymous Identification of the End User 736
Working with Anonymous Identification 739
Anonymous Options for Personalization Properties 739
Warnings about Anonymous User Profile Storage 740
xviii
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xix

Contents
Programmatic Access to Personalization 741
Migrating Anonymous Users 741
Personalizing Profiles 743
Determining Whether to Continue with Automatic Saves 744
Personalization Providers 745
Working with SQL Server Express Edition 745
Working with Microsoft’s SQL Server 7.0/2000/2005/2008 746
Using Multiple Providers 748
Managing Application Profiles 749
Properties of the ProfileManger Class 750
Methods of the ProfileManager Class 750
Building the ProfileManager.aspx Page 751
Examining the Code of ProfileManager.aspx Page 754
Running the ProfileManager.aspx Page 755
Summary 755
Chapter 16: Membership and Role Management 757
Authentication 758
Authorization 758
ASP.NET 3.5 Authentication 758
Setting Up Your Web Site for Membership 758
Adding Users 761
Asking for Credentials 776
Working with Authenticated Users 784
Showing the Number of Users Online 786
Dealing with Passwords 788
ASP.NET 3.5 Authorization 793
Using the LoginView Server Control 793
Setting Up Your Web Site for Role Management 796
Adding and Retrieving Application Roles 799

Deleting Roles 801
Adding Users to Roles 802
Getting All the Users of a Particular Role 803
Getting All the Roles of a Particular User 805
Removing Users from Roles 805
Checking Users in Roles 806
Understanding How Roles Are Cached 807
Using the Web Site Administration Tool 809
Public Methods of the Membership API 809
Public Methods of the Roles API 810
Summary 810
xix
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xx
Contents
Chapter 17: Portal Frameworks and Web Parts 811
Introducing Web Parts 811
Building Dynamic and Modular Web Sites 813
Introducing the WebPartManager Control 813
Working with Zone Layouts 814
Understanding the WebPartZone Control 817
Allowing the User to Change the Mode of the Page 820
Modifying Zones 833
Working with Classes in the Portal Framework 841
Creating Custom Web Parts 844
Connecting Web Parts 850
Building the Provider Web Part 851
Building the Consumer Web Part 854
Connecting Web Parts on an ASP.NET Page 856
Understanding the Difficulties in Dealing with Master Pages When Connecting Web Parts 858
Summary 860

Chapter 18: HTML and CSS Design with ASP.NET 861
Caveats 862
HTML and CSS Overview 862
Introducing CSS 863
Creating Style Sheets 863
CSS Rules 866
CSS Inheritance 875
Element Layout and Positioning 876
Working with HTML and CSS in Visual Studio 884
ASP.NET 2.0 CSS–Friendly Control Adapters 893
Summary 893
Chapter 19: ASP.NET AJAX 895
Understanding the N eed for AJAX 895
Before AJAX 896
AJAX Changes the Story 897
ASP.NET AJAX and Visual Studio 2008 899
Client-Side Technologies 900
Server-Side Technologies 900
Developing with ASP.NET AJAX 901
ASP.NET AJAX Applications 902
Building a Simple ASP.NET Page Without AJAX 904
Building a Simple ASP.NET Page with AJAX 906
xx
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xxi
Contents
ASP.NET AJAX’s Server-Side Controls 911
The ScriptManager Control 912
The ScriptManagerProxy Control 914
The Timer Control 916
The UpdatePanel Control 917

The UpdateProgress Control 922
Using Multiple UpdatePanel Controls 925
Summary 928
Chapter 20: ASP.NET AJAX Control Toolkit 929
Downloading and Installing 929
New Visual Studio Templates 931
Adding the New Controls to the VS2008 Toolbox 932
The ASP.NET AJAX Controls 934
ASP.NET AJAX Control Toolkit Extenders 937
AlwaysVisibleControlExtender 937
AnimationExtender 939
AutoCompleteExtender 941
CalendarExtender 944
CollapsiblePanelExtender 946
ConfirmButtonExtender and ModalPopupExtender 947
DragPanelExtender 950
DropDownExtender 951
DropShadowExtender 953
DynamicPopulateExtender 956
FilteredTextBoxExtender 959
HoverMenuExtender 961
ListSearchExtender 962
MaskedEditExtender and MaskedEditValidator 964
MutuallyExclusiveCheckBoxExtender 967
NumericUpDownExtender 968
PagingBulletedListExtender 969
PopupControlExtender 970
ResizableControlExtender 972
RoundedCornersExtender 975
SliderExtender 976

SlideShowExtender 977
TextBoxWatermarkExtender 979
ToggleButtonExtender 982
UpdatePanelAnimationExtender 983
ValidatorCalloutExtender 984
xxi
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xxii
Contents
ASP.NET AJAX Control Toolkit Server Controls 985
Accordion Control 986
NoBot Control 988
PasswordStrength Control 990
Rating Control 991
TabContainer Control 993
Summary 994
Chapter 21: Security 995
Authentication and Authorization 996
Applying Authentication Measures 996
The <authentication> Node 997
Windows-Based Authentication 998
Forms-Based Authentication 1006
Passport Authentication 1016
Authenticating Specific Files and Folders 1016
Programmatic Authorization 1017
Working with User.Identity 1018
Working with User.IsInRole() 1019
Pulling More Information with WindowsIdentity 1020
Identity and Impersonation 1023
Securing Through IIS 1025
IP Address and Domain Name Restrictions 1025

Working with File Extensions 1027
Using the ASP.NET MMC Snap-In 1031
Using the IIS 7.0 Manager 1032
Summary 1032
Chapter 22: State Management 1033
What Are Your Choices? 1034
Understanding the Session Object in ASP.NET 1036
Sessions and the Event Model 1036
Configuring Session State Management 1038
In-Process Session State 1038
Out-of-Process Session State 1046
SQL-Backed Session State 1051
Extending Session State with Other Providers 1056
Cookieless Session State 1057
Choosing the Correct Way to Maintain State 1058
The Application Object 1059
QueryStrings 1060
xxii
Evjen ftoc.tex V2 - 01/28/2008 5:00pm Page xxiii
Contents
Cookies 1060
PostBacks and Cross-Page PostBacks 1061
Hidden Fields, ViewState, and ControlState 1063
Using HttpContext.Current.Items for Very Short-Term Storage 1067
Summary 1069
Chapter 23: Caching 1071
Caching 1071
Output Caching 1071
Partial Page (UserControl) Caching 1074
Post-Cache Substitution 1075

HttpCachePolicy and Client-Side Caching 1078
Caching Programmatically 1080
Data Caching Using the Cache Object 1080
Controlling the ASP.NET Cache 1081
Cache Dependencies 1081
Using the SQL Server Cache Dependency 1087
Enabling Databases for SQL Server Cache Invalidation 1088
Enabling Tables for SQL Server Cache Invalidation 1088
Looking at SQL Server 2000 1089
Looking at the Tables That Are Enabled 1090
Disabling a Table for SQL Server Cache Invalidation 1090
Disabling a Database for SQL Server Cache Invalidation 1091
SQL Server 2005 Cache Invalidation 1091
Configuring Your ASP.NET Application 1092
Testing SQL Server Cache Invalidation 1094
Adding More Than One Table to a Page 1096
Attaching SQL Server Cache Dependencies to the Request Object 1096
Attaching SQL Server Cache Dependencies to the Cache Object 1097
Summary 1101
Chapter 24: Debugging and Error Handling 1103
Design-Time Support 1103
Syntax Notifications 1104
Immediate and Command Window 1106
Task List 1106
Tracing 1107
System.Diagnostics.Trace and ASP.NET’s Page.Trace 1108
Page-Level Tracing 1108
Application Tracing 1108
Viewing Trace Data 1109
xxiii

×