Pro ASP.NET 3.5 Server Controls and AJAX Components is a reference for the serious ASP.NET developer who understands the benefits of object–oriented development and wants to apply those principles to ASP.NET 3.5, ASP.NET AJAX, and server control development. This book also covers SharePoint and targets the latest version of Visual Studio (2008) and the .NET Framework (3.5). Highlights include the following: Covers the new features in ASP.NET 3.5 and ASP.NET AJAX technology Describes the ASP.NET server control architecture in Visual Studio 2008/ASP.NET 3.5 covering state management, events, rendering, cross-platform support, control life cycle, localization, and deployment Demonstrates how to integrate client–side development technologies such as DHTML and JavaScript with server control technology to create powerful interactive controls What you’ll learn Create a powerful suite of interactive controls using ASP.NET 3.5 and ASP.NET AJAX Enrich the design–time experience when building custom server controls Integrate client–side development technologies such as DHTML and JavaScript with server control technology Develop SharePoint server controls Learn the background on user controls as compared to server controls Work with the new mobile controls in ASP.NET 3.5 Who this book is for The serious ASP.NET developer who understands the benefits of object-oriented development and wants to apply those principles to ASP.NET 3.5 and server control development.
Author(s): Dale Michalk, Rob Cameron
Publisher: Apress
Year: 2008
Language: English
Pages: 752
Contents at a Glance......Page 3
Contents......Page 4
About the Authors......Page 13
About the Technical Reviewer......Page 14
Acknowledgments......Page 15
How This Book Is Structured......Page 16
Contacting the Authors......Page 17
The Heart and Soul of ASP.NET......Page 18
A .NET Framework fiHelo, WorldflWeb Form......Page 19
Control Properties......Page 24
Control Events......Page 26
The Web Page As a Control Tree......Page 28
The Root Controls......Page 30
System.Web.UI.HtmlControls Namespace......Page 31
An HTML Controls Demonstration......Page 33
The System.Web.UI.WebControls Namespace......Page 37
A Simple Controls Demonstration......Page 38
A List Controls Demonstration......Page 42
Rich Controls......Page 45
A Rich Controls Demonstration......Page 46
An XML Control and XSLT Demonstration......Page 48
Validation Controls......Page 51
A Validation Controls Demonstration......Page 52
Web Controls vs. HTML Controls......Page 57
Summary......Page 58
Packaging Content in ASP.NET......Page 59
Inheritance......Page 60
User Controls......Page 61
Custom Server Controls......Page 65
Building a User Control......Page 68
The MenuUserControl User Control......Page 69
Using the MenuUserControl User Control......Page 70
The TableUserControl User Control......Page 71
Using the TableUserControl User Control......Page 73
Which Base Class?......Page 76
Rendered or Composite Control?......Page 77
Using the MenuCustomControl Server Control......Page 79
The TableCustomControl Server Control via Rendering......Page 81
Using the Custom Table Controls......Page 88
Inheriting from an Existing Server Control......Page 91
ASP.NET AJAX UpdatePanel Server Control......Page 94
ASP.NET AJAX UpdateProgress Server Control......Page 95
What’s an Attribute?......Page 98
Common Design-Time Attributes......Page 99
Summary......Page 100
ASP.NET Request-Processing Architecture......Page 101
HttpHandler......Page 103
The Context Object......Page 104
ASP.NET and Client-Side State Management......Page 105
Cookies......Page 106
HTML Hidden Variables......Page 107
ViewState......Page 109
The StateBag Class and the IStateManager Interface......Page 110
Ease of Use......Page 111
A Client State Workshop......Page 112
Reading the Client State......Page 116
Getting the URL State......Page 117
The StatelessLabel Server Control......Page 118
The StatefulLabel Server Control......Page 119
Comparing the Labels......Page 120
Setting the Label Control State......Page 122
Testing Control ViewState......Page 123
The IPostBackDataHandler Interface......Page 124
The Textbox Control......Page 125
Using the Textbox Control......Page 127
ViewState Is Now Application User State......Page 131
New TextBox3d Demonstration Web Form......Page 132
Adding Control State to TextBox3D......Page 134
Summary......Page 137
Customizing the Appearance of Controls......Page 139
Styling Using Cascading Style Sheets......Page 140
Style Properties and Visual Studio......Page 143
WebControl and Control Styling......Page 146
WebControl’s ControlStyle Property......Page 147
WebControl Top-Level Style Properties......Page 148
The Style Property......Page 149
A Styled Label Control......Page 150
The AddAttributesToRender() Method......Page 151
A Styled TextBox Control......Page 152
The Web Control Style Web Form......Page 155
Styles, HTML 3.2, and Down-Level Browsers......Page 163
The Styled InputBox Control......Page 165
LabelStyle and TextBoxStyle......Page 168
Customizing ViewState......Page 169
Rendering the Output......Page 170
The InputBox Style Web Form......Page 174
Applying the LabelStyle and TextBoxStyle Settings......Page 179
The CursorStyle Enumeration......Page 182
The FancyLabel Control......Page 187
Rendering the FancyLabel Control......Page 188
The FancyLabel Style Web Form......Page 190
The StyleCollection Class......Page 194
Summary......Page 197
The Need for Events in ASP.NET......Page 199
The .NET Framework Event Model......Page 201
Delegates......Page 202
Working with Delegates......Page 203
System.EventHandler Delegate......Page 206
Enhancing the TextBox Control with a TextChanged Event......Page 207
Using the TextBox Control on a Web Form......Page 210
Creating a TextChangedEventArgs Class......Page 214
Creating a TextChangedEventHandler Delegate......Page 215
Adding an Event to the CustomEventTextBox Control......Page 216
Using the CustomEventTextBox Control on a Web Form......Page 219
Rendering the Button......Page 223
Exposing a Click Event and the Events Collection......Page 225
Exposing the Command Event......Page 227
Capturing the Postback via IPostBackEventHandler......Page 229
Using the SuperButton Control on a Web Form......Page 233
Building the Pager Child Control Hierarchy......Page 240
Defining the PageCommand Event......Page 242
Exposing the PageCommand Event from the Pager Control......Page 243
Capturing the Bubbles via OnBubbleEvent......Page 244
The INamingContainer Interface......Page 245
Using the Pager Control on a Web Form......Page 249
Control Life Cycle......Page 253
Plugging Into the Life Cycle......Page 254
Life Cycle and the HTTP Protocols GET and POST......Page 255
TrackViewState Method......Page 261
Render Method......Page 262
HTTP POST Request via Postback......Page 263
LoadPostBackData Method......Page 265
Summary......Page 266
Customized Control Content......Page 268
The ParseChildren Attribute......Page 269
A Menu Control with Templates......Page 271
The Template Properties......Page 272
Creating the Header Section......Page 273
Creating the Hyperlink Section......Page 275
Viewing the TemplateMenu Control......Page 281
The TagDataMenu Control......Page 283
The BuilderMenuControl......Page 288
Viewing the Tag Parsing Menu Controls......Page 293
Summary......Page 295
Server Control Data Binding......Page 296
DataBinding Base Class Options......Page 297
The Repeater Control......Page 298
The RepeaterItem Container Control......Page 299
Command Events and the RepeaterItem Control......Page 301
The Repeater Control Architecture......Page 304
Repeater Control Event Management......Page 317
Data Binding with the Repeater Control......Page 327
Advanced Interaction with the Repeater Control......Page 333
The Dynamic Templates Web Form......Page 338
Implementing the ITemplate Interface......Page 344
CompositeDataBoundControl......Page 349
The EnhancedSpreadsheetControl......Page 350
Summary......Page 359
Client-Side Script Server Control Scenarios......Page 361
Handling Client-Side Events......Page 362
The Click Web Form......Page 364
Handling Mouse Events for Image Rollovers......Page 366
JavaScript Detection......Page 367
Rendering Client Script Code......Page 368
Rendering the HTML Code......Page 371
The RolloverImage Web Form......Page 376
Analyzing the Rollover HTML Output......Page 379
The FormConfirmation Control......Page 380
The ConfirmedLinkButton Control......Page 381
The Confirm Web Form......Page 383
The UpDown Server Control......Page 388
Key Properties: MinValue, MaxValue, Increment, and Value......Page 389
Preparing the Script for Rendering......Page 391
Creating the Child Controls......Page 395
The ValueChanged Event......Page 396
Retrieving the Data......Page 397
Handling Child Control Events......Page 398
The UpDown Web Form......Page 406
Client Callbacks......Page 409
The Callback Web Form......Page 410
The StockNews Callback Control......Page 418
Summary......Page 426
ASP.NET AJAX......Page 427
SimpleUserControlAJAX Demonstration......Page 428
ASP.NET AJAX Extensibility......Page 430
The GetScriptReferences Method......Page 431
The GetScriptDescriptors Method......Page 432
HoverButton Example......Page 433
The TextCaseExtender Control......Page 440
The TextCaseBehavior Client-Side Component......Page 442
The HighlightedHyperLink ASP.NET AJAX Server Control......Page 446
The HighlightedHyperlink Client-Side Component......Page 449
Summary......Page 454
Web-Part-Based Web Site Development......Page 455
Web Part Infrastructure......Page 456
Creating Web Parts......Page 457
The Server Controls......Page 458
Converting to WebPart Controls......Page 467
The WebPartPageController Server Control......Page 469
Wiring Up the Page......Page 477
Web Part Development Tips......Page 490
Nonmobile Adaptive Behavior......Page 491
Control Adapters......Page 492
The PageAdapter Base Class......Page 493
The WebControlAdapter Base Class......Page 494
Working in Visual Studio 2008......Page 496
Mobile Controls Quick Primer......Page 497
System.Web.UI.MobileControls Controls......Page 498
Browsing Mobile Web Forms......Page 501
Customizing and Implementing Mobile Controls......Page 502
The StyleSheet Control......Page 503
The StyleSheetExternal Mobile Web Page......Page 504
The DeviceSpecific.aspx Mobile Web Page......Page 505
Templates......Page 506
The DeviceSpecific and Choice Elements......Page 507
Filter Attribute and deviceFilters Configuration......Page 508
MobileCapabilities, browserCaps, and Device Update 2......Page 509
Custom Device Adapters and Mobile Controls......Page 510
New Capabilities in MobileCapabilities......Page 511
User Controls......Page 516
Miniaturizing the Header and Footer......Page 517
Custom Controls......Page 518
Device Adapters......Page 519
Mobile Control and Adapter Interaction......Page 521
Managing ViewState......Page 523
Inheriting from MobileControl......Page 525
The MCTextBox Control......Page 526
The HTML Device Adapter......Page 529
The WML Device Adapter......Page 531
Testing MCTextBox......Page 533
Summary......Page 535
Design-Time Architecture......Page 537
Environment Services Overview......Page 538
Customizing Component Behavior......Page 540
The TitledThumbnail Control......Page 541
The TitledThumbnail Control at Design Time......Page 546
The Properties Window......Page 547
The LocationConverter Class......Page 552
The ImageMetaDataConverter Class......Page 556
The SimpleTextEditor Editor......Page 559
The Collection Editor......Page 562
The Component Editor Dialog Box......Page 564
The Component Editor Class......Page 569
Custom Designers......Page 572
The Control Designer and Designer Verbs......Page 574
The Templated Control Designer......Page 578
The Data-Bound Control Designer......Page 582
The RepeaterDesigner Class......Page 583
Debugging Design-Time Development......Page 587
Summary......Page 588
The Problem Domain......Page 590
The Live Search Web Service......Page 591
Web Services Description Language and .NET Web Service Proxies......Page 592
Creating the Control Library Project......Page 596
Bin Directory or Global Assembly Cache Deployment......Page 597
Additional Assembly Attributes......Page 598
Crafting the Configuration Section XML......Page 599
Registering the Configuration Section......Page 600
Building a Configuration Section Handler Class......Page 602
Wrapping the Web Service Proxy in a Utility Method......Page 604
Designing the Control Architecture......Page 606
The Search Control......Page 608
Handling the Search......Page 609
The Result Control......Page 617
The ResultItem Control......Page 618
The Blank Scenario......Page 622
The DataBind Scenario......Page 623
Creating a Control Hierarchy for Data Binding or Postback......Page 624
Creating ResultItem Controls......Page 627
Creating the Child Pager Control......Page 629
Managing Paging......Page 630
Styling the Result Control......Page 631
The Pager Control......Page 656
Creating the Pager Results......Page 657
Creating the Pager’s Previous Button......Page 658
Creating the Pager’s Bar Pages......Page 659
Creating the Pager’s Next Button......Page 660
Ensuring Pager’s Style Rendering......Page 661
Summary......Page 668
Designers and Dummy Data Source......Page 669
Template Support in the Result Control......Page 678
Toolbox Image Icons......Page 682
The Default Look and Feel......Page 683
Customizing the Live Search Controls’ Appearance......Page 686
Licensing Support......Page 689
The RsaLicense License......Page 690
License Cryptography......Page 693
Generating the License......Page 695
The RsaLicenseDataAttribute Custom Attribute......Page 697
Adding Licensing to the Search and Result Controls......Page 698
The RsaLicenseProvider Class......Page 700
The CultureInfo Class......Page 708
The ResourceManager Class......Page 709
Culture Types and Localizing Resource Files......Page 712
Satellite Assemblies and Resource Fallback......Page 714
Setting Thread Culture in the Global.asax File......Page 716
Viewing a Localized Web Form......Page 717
Code Analysis for Managed Code......Page 721
Documentation......Page 723
Summary......Page 724
Index......Page 725