ASP.NET AJAX Programmer’s Reference with ASP.NET 2.0 or ASP.NET 3.5 Dr Shahram Khosravi Wiley Publishing, Inc ffirs.indd v 8/25/07 2:41:01 AM ffirs.indd iv 8/25/07 2:41:00 AM ASP.NET AJAX Programmer’s Reference with ASP.NET 2.0 or ASP.NET 3.5 Acknowledgments xi Introduction xxix Chapter 1: AJAX Technologies Chapter 2: JavaScript Base Type Extensions 27 Chapter 3: Built-In and Custom Exception Types 53 Chapter 4: JavaScript Object-Oriented Programming and Type Reflection Extensions 77 Chapter 5: Event Programming Extensions 131 Chapter 6: DOM Extensions 161 Chapter 7: Component Development Infrastructure 219 Chapter 8: Developing Client Controls 281 Chapter 9: Event Bubbling and Button Client Control 323 Chapter 10: Type Description Extensions 349 Chapter 11: Data Classes 407 Chapter 12: Client-Server Communications 457 Chapter 13: Consuming Web Services Via Soap Messages 511 Chapter 14: Consuming Web Services Via JSON Messages 535 Chapter 15: Proxy Classes 597 Chapter 16: Behaviors 659 Chapter 17: Script and Extender Server Controls 707 Chapter 18: Web Services Bridges and Transformers 773 Chapter 19: UpdatePanel and ScriptManager 857 Chapter 20: Using UpdatePanel in User Controls and Custom Controls 911 Chapter 21: Page Life Cycle and Asynchronous Partial Page Rendering 965 Chapter 22: ASP.NET AJAX Client-Side PageRequestManager 1033 Continues ffirs.indd i 8/25/07 2:41:00 AM Chapter 23: Asynchronous Partial Page Rendering: Server Side Processing 1105 Chapter 24: Asynchronous Partial Page Rendering: Client-Side Processing 1179 Appendix A: XML Script 1275 Appendix B: Binding 1325 Appendix C: Actions 1341 Appendix D: Data Control 1357 Appendix E: Templated Controls 1381 Appendix F: ListView 1409 Index 1481 ffirs.indd ii 8/25/07 2:41:00 AM ASP.NET AJAX Programmer’s Reference with ASP NET 2.0 or ASP.NET 3.5 ffirs.indd iii 8/25/07 2:41:00 AM ffirs.indd iv 8/25/07 2:41:00 AM ASP.NET AJAX Programmer’s Reference with ASP.NET 2.0 or ASP.NET 3.5 Dr Shahram Khosravi Wiley Publishing, Inc ffirs.indd v 8/25/07 2:41:01 AM ASP.NET AJAX Programmer’s Reference with ASP.NET 2.0 or ASP.NET 3.5 Published by Wiley Publishing, Inc 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2007 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-10998-4 Manufactured in the United States of America 10 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600 Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose No warranty may be created or extended by sales or promotional materials The advice and strategies contained herein may not be suitable for every situation This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services If professional assistance is required, the services of a competent professional person should be sought Neither the publisher nor the author shall be liable for damages arising herefrom The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S at (800) 762-2974, outside the U.S at (317) 572-3993 or fax (317) 572-4002 Library of Congress Cataloging-in-Publication Data: Khosravi, Shahram, 1963ASP.NET Ajax programmer’s reference / Shahram Khosravi p cm Includes index ISBN 978-0-470-10998-4 (paper/website) Active server pages Internet programming Web site development Ajax (Web site development technology) Microsoft NET I Title TK5105.8885.A26K538 2007 005.2'76 dc22 2007024239 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc and/or its affiliates, in the United States and other countries, and may not be used without written permission All other trademarks are the property of their respective owners Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available in electronic books ffirs.indd vi 8/25/07 2:41:01 AM About the Author Shahram Khosravi, Ph.D., is a senior software engineer, consultant, author, and instructor specializing in ASP.NET, Windows Communications Foundation (WCF), ASP.NET AJAX, Windows Workflow Foundation (WF), IIS7 and ASP.NET Integrated Programming, ADO.NET, Web services, NET, and XML technologies such as XSD, XSLT, XPath, SOAP, and WSDL He also has years of experience in object-oriented analysis, design, and programming, architectural and design patterns, service-oriented analysis, design, and programming, 3D computer graphics programming, user interface design, and usability Shahram is the author of the following four books: Professional ASP.NET 3.5 and NET 3.5 Programming (ASP.NET Internals plus ASP.NET AJAX, IIS 7.0, Enterprise Library Application Blocks, Windows Workflow Foundation, and Windows Communication Foundation), ASP.NET AJAX Programmer’s Reference with ASP NET 2.0 or ASP.NET 3.5, Professional IIS7 and ASP.NET Integrated Programming, and Professional ASP.NET Server Control and Component Development He has written articles on the ASP.NET, ADO.NET, NET, and XML technologies for the industry’s leading magazines, such as Dr Dobb’s Journal, asp.netPRO magazine, and Microsoft MSDN Online ffirs.indd vii 8/25/07 2:41:01 AM properties (continued) properties (continued) BaseMasterDetailControl server control, 903–904 BaseMasterDetailControl2 server control, 910 Behavior class, 668 Component class, 351–352 components, 727 control states and, 898 DomEvent class, 187–189 getProperties method, 1298 _getProperties method, 1306 HtmlGenerator client control, 801–802 HtmlGeneratorScriptControl server control, 807 INotifyPropertyChanged interface, 228–233 MasterDetailControl server control, 916 MasterDetailControl2 server controls, 924 OOP and type reflection extensions, 78–79 popStackFrame, error types, 45 Result/Results classes, 833–835 ShoppingCartItem class, 141–144 style properties, 1387, 1401–1402, 1444–1447 template properties, 1447–1450 TypeDescriptor class, 351–358 XMLHttpRequest class, 5–6 properties collection, 1299–1300 properties parameter create method of Component base class, 249, 276–277, 662 HyperLink client controls, 320 in Image client control example, 301 Image client controls, extending, 313–314 PropertyChangedEventArgs, 235 protected virtual methods, 900 prototype property Button client control, 325–326 HyperLink client controls, 315 Image client controls, 298 Image client controls, extending, 307 JavaScript Function type, 78 Label client controls, 294 Type class, 80 proxy classes, 597–657 associated with custom classes, 607 associated with page methods, 605–607 associated with Web services, 600–605 automatic generation of, 607–608 client proxy REST requests, 576 ClientProxyGenerator class See ClientProxyGenerator class declarative approach, 608–618 deriving from Sys.Net.WebServiceProxy class, 602 EnablePageMethods, 626 imperative approach, 618–620 methods for creating, 777 OnInit method, 626–627 overview, 597–599 Page_PreRenderComplete, 627 parent/child pages, 621–623 proxy objects acting as a proxy for remote objects, 599–600 RestClientProxyHandler, 647–649 ScriptManager replica, 624–625 ServiceReference replica, 627–629 Services collection replica, 625–626 types of, 600 using, 649–657 public methods ScriptComponentDescriptor class, 726–728 wrapper methods as, 564 Q queueCustomScriptTag method, _ScriptLoader class, 1204 queues, enqueue and dequeue array methods, 31–33 queueScriptBlock method, _ScriptLoader class, 1204 queueScriptReference method, _ScriptLoader class, 1205 QuoteString method, HelperMethods class, 725 R Raise Post Data Changed Event phase, page postbacks, 1112–1113 raiseBubbleEvent method Control base class, 290 in custom client control, 337 inherited from Control class, 329–330 raiseLoad method, Application class, 256 RaisePostDataChangedEvent method Raise Post Data Changed Event phase, 1112–1113 ScriptManager class, 1109 raise_propertyChanged method, INotifyPropertyChanged interface, 233 raisePropertyChanged method 1510 bindex.indd 1510 8/21/07 2:13:53 AM behaviors, 667–668 component development, 270–271 set_data method, 1354 triggerChangeEvents method, 1351 readLoadedScripts method, _ScriptLoader class, 1202–1203 ReadXml method, IXmlSerializable interface, 839 readyState property, XMLHttpRequest, references parameter create method of Component base class, 249, 277, 663 HyperLink client controls, 321 in Image client control example, 301–302 Image client controls, extending, 314 RegisterAsyncPostBackControl method PageRequestManager, 1012–1014 ScriptManager, 1011–1012 registerClass method defining classes before registering, 90–92 JavaScript OOP and type reflection extensions, 81–83 RegisterDataItem method PageRequestManager, 1137–1138 ScriptManager, 1136–1137 RegisterDetailEventHandlers method, BaseMasterDetailControl2, 909 RegisterDisposeForDescriptor method, ScriptDescriptor class, 717 registerDisposeScript method, postback methods, 1187–1188, 1201 registerEnum method, JavaScript OOP and type reflection extensions, 127–128 RegisterExtenderControl method, ScriptManager class, 712, 740 _registerHandlerForFormSubmitEvent method, _initializeInternal method, 1043 _registerHandlerFormClickEvent method, _initializeInternal method, 1044 _registerHandlerForWindowLoadEvent method, _initializeInternal method, 1044 _registerHandlerForWindowUnloadEvent method, _initializeInternal method, 1044–1045 registering classes, JavaScript, 81–83 registerInterface method, JavaScript OOP and type reflection extensions, 89–92 RegisterMasterEventHandlers method MasterDetailControl server control, 914 MasterDetailControl2 server control, 923 registerNamespace method, JavaScript OOP and type reflection extensions, 85–87 Index Render children method, page postback RegisterPanel method, UpDatePanel, 982–983 registerPartialUpdateEvents method, BehaviorBase class, 683–684 registerPropertyChanged method, TextBoxWatermarkBehavior class, 695–696 RegisterScriptControl method, ScriptManager class, 740 RegisterScriptDescriptors method, ScriptManager class, 744–746 RegisterUpdatePanel method PageRequestManager, 984 ScriptManager, 983 ReleaseHandler method, ScriptHandlerFactory, 571 remote objects, proxy objects for, 599–600 remove, array types, 36 remove method, deleteCurrentItem method, 1360–1361 removeAt, array types, 37 remove_beginRequest method, 1099 remove_click method, HyperLink client controls, 317 remove_completed method, WebRequestExecutor class, 461 remove_completedRequest method, 471 removeComponent method Application class, 241 IContainer class component, 238 removeCssClass method Control base class, 288 DomElement methods, 167–169 remove_disposing method behaviors, 667 INotifyDisposing interface, 224 Monitor class implementing, 227 removeHandler method DomEvent class, 193–194 Sys.EventHandlerList class, 134–135 System.ComponentModel.EventHandlerList class, 131 remove_initializeRequest method, 1091 remove_invokingRequest method, 471 remove_pageLoaded method, 1053 remove_propertyChanged method behaviors, 667 INotifyPropertyChanged interface, 229, 233 Render children method, page postback, 1114–1115 1511 bindex.indd 1511 8/21/07 2:13:53 AM render method render method CustomTable template data control, 1387–1390 developing custom data control, 1366 ListView control, 1458–1463 rendering page postbacks server side, 1114 ScriptManager, 1020–1027 of ScriptManager server control, 1070–1071 set_data method, 1354 UpdatePanel, 1028–1029 Render method Control class, 1114 extender control, 761 script control, 768 RenderChildren method Control class, 1114–1115 HtmlForm server control, 1128 UpdatePanel server control, 1130–1131, 1156 renderComplete event, ListView control, 1452 RenderContainer method, BaseMasterDetailControl, 900 RenderContents method AmazonSearchScriptControl, 796–798 BaseMasterDetailControl, 902–903 RenderControl method HtmlForm, 1127–1132 RenderChildren method and, 1114–1115 RenderPageCallback method and, 1118 RenderDataItems method, page postback, 1134– 1138, 1157 Renderer, AJAX engine components, RenderFormCallback method, PageRequestManager, 1128–1129 rendering aspect, partial page rendering overview of, 1019–1020 Render method of ScriptManager, 1020–1027 Render method of UpdatePanel, 1028–1029 RenderMethod, RenderPageCallback method, 1117 RenderPageCallback method EncodeString method calls triggered by, 1159–1161 OnPreRender method, 1113–1114 page postbacks server response, 1155–1156 rendering page postbacks server side, 1116–1121 _renderTaskComplete method, ListView control, 1471 RenderUpdatePanelIDsFromList method, PageRequestManager, 1024–1025 request messages, WSDL documents, 515–516 request processing, partial page rendering, 966–969 request processing pipeline, In ASP.NET, 587–588 RequiresUpdate method, UpdatePanel server, 1124–1126 resolveInheritance method, JavaScript OOP and type reflection extensions, 103–104 ResolveScriptReference event, ScriptManager class, 746–748 response messages, WSDL documents, 515–516 responseText property, XMLHttpRequest, responseXML property, XMLHttpRequest, REST method calls, 576 REST requests, JSON ASP.NET AJAX framework supported, 576 RestHandlerFactory and, 574–576 ScriptHandlerFactory and, 573 RestClientProxyHandler, proxy classes, 647–649 RestHandlerFactory CreateHandler method, 590–591 implementation of, 574–577 instantiating instances of, 572–573 replica of, 577–582 Result.cs file, 837 Result/Results classes AmazonSearch2.aspx page code listing, 838–839 code listing, 835–836, 840–841 definition and annotation of, 832–835 implementing IXmlSerializable interface See IXmlSerializable interface properties, 833–835 xsd.exe utility for generating, 837 ResultsSchema method, IXmlSerializable interface, 842–844 RetrievePostData method, Page object, 1098, 1101 RetrievePostData phase, page postbacks, 1097–1101 return value types, WSDL documents, 515 revealTrans filter exposing duration property, 309 exposing transition property, 310 rightButton value, MouseButton class, 176 _rootNamespaces array, 87 rowIndex property, GridViewRow control, 339 rows See DataRow class 1512 bindex.indd 1512 8/21/07 2:13:54 AM S SaveViewState method BaseMasterDetailControl, 899 HtmlGeneratorScriptControl, 810 scheduler, AJAX engine components, script controls AmazonSearchScriptControl server control See AmazonSearchScriptControl server control extender controls compared with, 769–770 IScriptControl interface, 713–714 overview of, 708, 713 ScriptBehaviorDescriptor class, 730–732 ScriptComponentDescriptor class See ScriptComponentDescriptor class ScriptControl base class, 714–716 ScriptControlDescriptor class, 730 ScriptDescriptor class, 716–717 ScriptManager class See ScriptManager class ScriptReference class, 732–733 ScriptReferenceCollection class, 733–734 summary, 771 why they are needed, 707–709 script controls, custom, 763–769 example using, 768–769 overview, 763–767 PreRender method, 767–768 Render method, 768 script HTML elements, 1274 ScriptBehaviorDescriptor class, 730–732 scriptBlock string, 1180 ScriptComponentDescriptor class AppendScript method, 729–730 GetScript method, 720–724 HelperMethods class and, 725–726 public methods, 726–728 replica of, 717–720 ScriptControl base class, 714–716 ScriptControlDescriptor class, 730 ScriptControls collection, 740 ScriptDataItem class, 1137 ScriptDataItemCollection class, 1138 ScriptDescriptor class, 716–717 scriptDispose string, 1183 ScriptHandlerFactory, 571–574 _ScriptLoader class, 1202–1211 constructor, 1210 _createScriptElement method, 1209 getInstance method, 1203 _getLoadedScripts method, 1205 Index ScriptManager class isScriptLoaded method, 1204 loadScripts method, 1205–1206 _loadScriptsInternal method, 1207–1209 queueCustomScriptTag method, 1204 queueScriptBlock method, 1204 queueScriptReference method, 1205 readLoadedScripts method, 1202–1203 _scriptLoaderHandler method, 1210–1211 server response to page postback, 1189–1191 _scriptLoaderHandler method, 1210–1211 _ScriptLoaderTask class constructor method of, 1211 execute method, 1212–1213 _scriptLoadHandler method, 1213 _scriptsLoadComplete method, 1213–1215 _scriptLoadHandler method, 1213 ScriptManager class AddScriptReferencesForScriptControls method, 743–744 CollectScripts method, 742–743 declarative approach to adding proxy classes, 608–618 ExtenderControls collection, 740 GetCurrent method, 741 imperative approach to adding proxy classes, 618–620 imperative approach to adding ServiceReference object to Services collection, 618 implementing IPostBackDataHandler, 1109 LoadScriptsBeforeUI property, 740 OnInit method, 741, 972–975, 1103 OnLoad method, 997 Page_PreRenderComplete method, 741–742 parent/child pages and, 621–623 RegisterAsyncPostBackControl method, 1011–1012 RegisterAsyncPostBackTrigger class, 1009 RegisterDataItem method, 1136–1137 RegisterExtenderControl method, 740 RegisterScriptControl method, 740 RegisterScriptDescriptors method for extender controls, 744–746 RegisterUpdatePanel method, 983 Render method, 1020–1027 replica, 624–625, 649–657, 734–739 ResolveScriptReference event, 746–748 ScriptControls collection, 740 Scripts collection property, 740 server control, 27–28 1513 bindex.indd 1513 8/21/07 2:13:54 AM ScriptManager class (continued) ScriptManager class (continued) ServiceReference object added to Services collection, 608 ScriptManager server controls BaseMasterDetailControl server control example See BaseMasterDetailControl server control master pages and content pages and, 874 partial page rendering and, 857 public registration methods of, 1146–1149 Render method of, 1070–1071 SetFocus method overloads of, 1152 ScriptManagerProxy server control, 621–623 ScriptModule, 583–591 aspx file requests and, 583–584 bypassing ASP.NET request processing pipeline, 587–589 IHttpModule interface and, 584 Init method, 586–587 OnPostAcquireRequestState method, 586 ScriptReference class, 732–733 ScriptReferenceCollection class, 733–734 ScriptRegistrationManager class, 1142–1146 internal collections of current, 1139–1142 script registration methods, 1142–1146 script-rendering methods of, 1149–1152 Scripts collection property, ScriptManager class, 740 _scriptsLoadComplete method, page postback, 1213–1215 SelectedIndex property, MasterDetailControl server control, 914–916 selectedItemClass property, ListView control, 1446–1447 selectionChangedCallback function, ListView control, 1421–1422 send method, XMLHttpRequest, separatorCssClass property, ListView control, 1447 separatorTemplate property, ListView control, 1449–1450 element, WSDL documents, 515 serialize function XML, 16 XMLHttpRequest, 12–14 server controls AmazonSearchScriptControl server control See AmazonSearchScriptControl server control benefits of ASP.NET, 24–25 Button server control, 325 client controls emulating, 290–291 composite See composite server controls extender controls See extender control GridView, 349 HyperLink, 315 master/detail forms, 881–882 script controls See script controls TypeDescriptor, 350 UpdatePanel See UpdatePanel server controls Web service bridges See AmazonSearchScriptControl server control server response text, arriving on client-side, 1171–1192 See also _onFormSubmitCompleted method appearance of, 1161–1170 checking type property, 1179–1184 completed method, 1172–1176 example of, 1176 _onFormSubmit method, 1171–1172 _onReadyStateChange method, 1172 parsing substrings, 1177–1179 server side methods client-side code for invoking, 570 static limitation of, 589 element, WSDL documents, 518 ServiceReference class automatic generation of proxy classes, 608 declarative approach to adding proxy classes, 608–618 imperative approach to adding proxy classes, 618–620 parent/child pages and, 621–623 replica of, 627–629 using Service Reference replica, 649–657 Services collection adding ServiceReference object to, 608, 621–623 imperative approach to adding ServiceReference object to, 618 parent/child pages and, 621 replica of, 625–626 set_alternateText method, Image client controls, 300 set_argument method, Button client control, 326 set_body method beginRequest event, 1104 WebRequest class, 459 set_command method, Button client control, 326–327 set_data method, DataControl class, 1353–1355 1514 bindex.indd 1514 8/21/07 2:13:54 AM set_dataIndex method DataControl class, 1356–1357 ListView control, 1450–1451 onBubbleEvent method, 1364–1365 set_default failed callback method, WebServiceProxy class, 536 set_default succeeded callback method, WebServiceProxy class, 536 set_element method, Behavior class, 669 set_events method, WebRequestExecutor class, 461 set_eventSource method, initializeObject method, 1314 setFocus method, ListView control, 1455–1456 SetFocus method, PageRequestManager, 1152–1154 set_headers method, WebRequestExecutor class, 460 set_height method, Image client controls, 299–300 set_httpVerb method, WebRequest class, 458 set_id method Behavior class, 671 Control base class, 284 INotifyPropertyChanged interface, 233–234 set_imageURI method, Image client controls, 299 set_imageURL method, Image client controls, 307–308 setLocation method, DomElement, 172–175 set_mouseOverImageURL methods, Image client controls, 308 set_name method, Behavior class, 669–670 set_navigateURL property, HyperLink client controls, 315 SetNoServerCaching method, RenderPageCallback method, 1117 setOwner method, actions, 1333 set_parent method, Control base class, 284 set_path, WebServiceProxy class, 537 _setPath method, TypeDescriptor class, 379–380 setProperty method SetPropertyAction, 1345 TypeDescriptor class, 377–382 SetPropertyAction Action class, 1345–1346 example using, 1336–1339 SetRenderMethodDelegate method, 1117 setRequestHeader method, XMLHttpRequest, set_rowIndex method, GridViewRow control, 339 Index SOAP messages set_target method, Action class, 1339 set_text method, Label client controls, 292–293 set_Text method, TextBoxWatermarkBehavior class, 697–698 setTimeout method, 1455–1456 set_timeout method WebRequest class, 459, 492 WebServiceProxy class, 535–536 set_url method, WebRequest class, 458, 492 set_visibilityMode method, Control base class, 286–287 set_visible method, Control base class, 287 set_WatermarkText method, 702 set_webRequest method, WebRequestExecutor class, 464 set_width method, Image client controls, 299 ShoppingCart class, 142–143 adding event handlers, 158–159 addShoppingCartItem method, 156–157 event programming base classes, 138 get_events method, 155 implementation of, 142–143 initialize method of ShoppingCart class, 155 methods, 154 onShoppingcartInitialized method, 155–156 onShoppingCartItemAdded method, 158 onShoppingCartItemAdding method, 158 removing event handlers, 159 supporting events, 144–152 ShoppingCartItem class, 141–142 event programming base classes, 138 properties and methods, 141–144 ShoppingCartItemAddedEventArgs event, event data class, 153–154 ShoppingCartItemAdding event, event data class, 152 simple properties, control states and, 898 SkinID property, MasterDetailField data control, 940 SOAP messages, 518–533 client-side code and, 518 example of page exchanging SOAP messages with Web service, 525–528 HTTP request message, 518–521 HTTP response message, 519–521 overview, 518 submitCallback function and, 528–533 WSDL documents determining methods, parameters, and return value of, 522–525 1515 bindex.indd 1515 8/21/07 2:13:55 AM HTML element HTML element example page containing, 660–661 Label client controls and, 291 _splitNodeIntoArray method, page postback, 1185 startsWith, string types, 40 _startTimeout method, TaskManager class, 1432–1433 state management methods BaseMasterDetailControl, 897–900 HtmlGeneratorScriptControl, 809–811 static methods array types, 28 Behavior class, 674–675 Component base class, 661–662 server side and, 589 static methods, DomEvent class, 189 addHandler method, 189–193 addHandlers method, 194–197 clearHandlers method, 197 removeHandler method, 193–194 status property, XMLHttpRequest, statusText property, XMLHttpRequest, stopPropagation method, DomEvent class, 201–203 _storeOriginalFormAction method, 1045 string types, 39–41 & symbol separating, 492 creating custom exceptions, 71 endsWith, 39 formatting, 41 overview, 39 startsWith, 40 trim, 40–41 StringBuilder class append method, 387 applendLine method, 387 clear method, 387 constructor, 387 CustomTable client control, 394 CustomTable client control and, 394 example of page using, 388–389 IsEmpty method, 388 overview, 385–387 pageLoadedHandler, 1063 toString method, 388–389 strings, JSON, 21–22 style applying to container controls, 896 ControlStyle property, 939–940 CustomTable template data control, 1387 styles, BaseMasterDetailControl overriding ControlStyle method, 902 overriding CreateControlStyle method, 902 styles, ListView control, 1401–1402, 1423– 1424, 1444–1447 subclasses, UpdatePane, 1001 Submit button, page postback via, 1040–1041 submit method, _doPostBack function invoking, 1041 submitCallback function in client-server communication example, 491–492 HTTP request message and, 528–533 Web requests using, 491–492 XMLHttpRequest, 11–12 Sys.CancelEventArgs class, 132–133 Sys.EventHandlerList class See EventHandlerList class Sys.IDisposable interface See IDisposable interface Sys.INotifyDisposing interface See INotifyDisposing interface Sys.INotifyPropertyChange interface See INotifyPropertyChanged interface Sys.Net.WebServiceProxy class See WebServiceProxy class Sys.Preview.UI namespace See Preview.UI namespace System.ComponentModel.CancelEventArgs class See ComponentModel class System.EventArgs class See EventArgs class Sys.UI.Behavior, 281 Sys.UI.Control, 281 T table rows applying to ListView control, 1424–1429 GridViewRow control, 337 TableCell, MasterDetailContainer derived from, 891 TableProvider class, DOM extensions, 216–217 tables custom control See CustomTable client control data tables See DataTable class TagKey property, BaseMasterDetailControl overriding, 902 target server control, of extender control, 711, 740 target URL, WebRequest class, 458 1516 bindex.indd 1516 8/21/07 2:13:55 AM _TaskManager, ListView control, 1430–1434 DOM element, 1425 DOM element, 1425–1429 Template class constructor, 1375 ITemplate interface, 1375 template containers, 987 template properties, ListView control, 1402–1403, 1447–1450 templated controls, 1373–1399 constructor, 1375 createInstance method, 1377–1380 developing custom template, 1380–1383 developing custom templated data control, 1383–1393 ITemplate interface, 1373–1374 methods, 1373 parseFromMarkup method, 1376–1377 partial page rendering, 987–994 Template type, 1375 TemplateInstance class, 1374 TemplateField custom template, 1380–1383 constructor, 1381 headerText property, 1381–1382 JavaScript file for, 1380–1381 parseFromMarkup method, 1382–1383 using, 1391–1393 TemplateInstance class, ITemplate interface, 1374 text Label client controls, 292–293 server response, 1161–1170 set_Text method, 697–698 WatermarkText methods, 702 TextBox control editing foreign key fields, 932 page containing DropDownList server control and, 1098–1099 TextBoxWatermarkBehavior class _applyWatermark method, 694–695 clearText method, 692–693 dispose method, 700–702 example page using, 703–706 initialize method, 688–691 _onBlur method, 693–694 _onFocus method, 691–692 _onKeyPress method, 695 _onPropertyChanged method, 696–697 _onSubmit method, 700 overview, 687–688 Index transformers _partialUpdateEndRequest method, 698–700 registerPropertyChanged method, 695–696 set_Text method, 697–698 WatermarkCssClass method, 702–703 WatermarkText method, 702 TextBoxWatermarkExtenderControl See extender control, custom TextBoxWatermarkScriptControl See script controls, custom TextProvider, DOM extensions, 184–185 themes applying to controls, 918–919 MasterDetailField data control, 940 timeout methods default timeout in WebRequestManager class, 469 WebRequest class, 459 WebServiceProxy class, 535–536 toggleCssClass method Control class, 288 CustomTable template data control, 1391 DomElement methods, 169–171 InvokeMethodAction, 1343–1344 render method, 1388–1389 toolkit See control toolkit toString method, StringBuilder class, 388–389 ToString transformer, 1327–1328 toUpperCase method _getTagType method using, 1280 initializeObject method, 1314 DOM element, 1425–1429 TrackViewState method BaseMasterDetailControl, 899 HtmlGeneratorScriptControl, 810–811 Transform method, XmlBridgeTransformer, 824–825 Transform method, XsltBridgeTransformer, 848–849 transformers, 1325–1326 BridgeTransformData class, 820–822 code listing, 813–814 Compare transformer, 1329 CompareInverted transformer, 1329 IBridgeResponseTransformer interface, 819–820 Invert transformer, 1328–1329 Invoke method instantiating, 819 steps in adding for specific method, 818–819 summary, 855 1517 bindex.indd 1517 8/21/07 2:13:55 AM transformers (continued) transformers (continued) tasks performed for each transform element in asbx files, 821–823 ToString transformer, 1327–1328 transformation of return value of method calls, 817–818 XmlBridgeTransformer See XmlBridgeTransformer XsltBridgeTransformer See XsltBridgeTransformer transition property, Image client controls, 310–311 TreeView server control in custom composite user control, 946, 956 displaying all messages, 957 triggerChangeEvents method addItem method, 1359 DataControl class, 1350–1351 deleteCurrentItem method, 1361 moveNext method, 1363 movePrevious method, 1363–1364 set_data method, 1354 triggers, UpdatePanel ChildrenAsTriggers property, 863–864 triggers causing asynchronous page postback, 877–878 UpdatePanelTrigger, 1000, 1004–1011, 1014–1018 UpdatePanelTriggerCollection, 998–1000 trim, string types, 40–41 true values, JSON, 21–22 try-catch-finally blocks, 41 Type class isClass method, 84 JavaScript OOP and type reflection extensions, 80 parse method, 125 type description dynamic injection of metadata information with, 399–400 ICustomTypeDescriptor class, 403–405 StringBuilder class in implementation of, 385 TypeDescriptor See TypeDescriptor class type parameter create method of Component base class, 249, 276, 662 HyperLink client controls, 320 Image client control, 301, 313 type property, 1179–1184 type reflection extensions, JavaScript See OOP and type reflection extensions TypeDescriptor class addAttribute method, 403 addEvent method, 402–403 addMethod method, 401–402 addProperty method, 400–401 append method, 371–374 constructor, 350 CustomTable client control, 389–399 _events, 364–368 generateDescriptor method, 370–371 getAttributed method, 376–377 getProperty method, 374–376 getPropertyType method, 384–385 getTypeDescriptor method, 369–370 initializeObject method, 1287–1288, 1298 invokeMethod method, 382–384 InvokeMethodAction invoking, 1342–1343 _methods, 358–364 overview, 349 _properties, 351–358 setProperty method, 377–382 SetPropertyAction invoking, 1345 element, WSDL documents, 514–515 U UI.Behavior, Component class, 281 UI.Control, Component class, 281 UniqueID properties, server controls, 1098 _uniqueIDToClientID method _doPostBack method, 1079 PageRequestManager, 1049 unload event, Application class, 260 Update method, Update Panel server, 1122 _updateControls method page postbacks, 1185, 1228–1230 PageRequestManager, 1046–1049 updated method, behaviors, 664 UpdatePanel add method for UpdatePanelTriggerCollection, 1003–1004 constructor of UpdatePanelTriggerCollection, 1001 ControlTemplate property, 987 CreateContents method, 984–987 Initialize method, 998 Initialize method of UpdatePanelTrigger, 1000, 1004–1011 1518 bindex.indd 1518 8/21/07 2:13:56 AM Initialize method of UpdatePanelTriggerCollection, 998–1000 OnInit method, 980–982 OnLoad method, 996–997 owner property of UpdatePanelTriggerCollection, 1002–1003 RegisterPanel method, 982–983 Render method, 1028–1029 subclasses of UpdatePanelTrigger, 1001 TreeView and DetailView as children of, 946 UpdatePanelControlTrigger class, 1004 _updatePanel method page postbacks, 1199–1200, 1230–1231 server response text arriving on client-side, 1187 UpdatePanel server controls attaching movers to, 1066–1067 BaseMasterDetailControl2 See BaseMasterDetailControl2 server control checking type property, 1179–1184 children as triggers, 863–864 code listing for page using conditional updates, 862–863 code listing for page using two UpdatePanel server controls, 860–861 direct inclusion of one UpdatePanels in another UpdatePanel, 864–867 EncodeString method call triggered by, 1156 imperative updates, 878–881 implementing IPostBackDataHandler, 1109 indirect inclusion of one UpdatePanels in another UpdatePanel via content page, 871–876 indirect inclusion of one UpdatePanels in another UpdatePanel via user control, 868–871 master server control contained in, 893 partial page rendering and, 857 RenderControl method of, 1129–1131 triggers causing asynchronous page postback, 877–878 _updatePanel method, 1199–1200 updating, 1184 UpdatePanelControlTrigger class, 1004 updatePanelIDs, 1181 updatePanelNodes array, 1187 UpdatePanelTrigger custom, 1014–1018 Initialize method, 1000, 1004–1011 subclasses, 1001 Index Web methods UpdatePanelTriggerCollection add method, 1003–1004 constructor, 1001 Initialize method, 998–1000 owner property, 1002–1003 triggers causing asynchronous page postback, 877 updates See UpdatePanel URLs element for specifying, 517 target URL for Web requests, 537 user controls UpdatePanel server control as parent of, 869–871 UpdatePanel server control encapsulated in, 868 user controls, partial-rendering enabled, 945 code listing, 947–952 deleting a message, 959–960 displaying all messages, 957–958 displaying details of a message, 958–959 overview, 945–946 replying to a message, 961–962 starting new thread, 963–964 updating a message, 960–961 XML document that stores message, 953–957 V _value collection, StringBuilder class, 385, 387–388 virtual methods, C#, 104 VisibilityMode properties, Control class, 286–287 W W3C, event propagation model, 202 WatermarkCssClass method custom extender control, 754 TextBoxWatermarkBehavior class, 702–703 watermarks See TextBoxWatermarkBehavior class WatermarkText methods custom extender control, 754 TextBoxWatermarkBehavior class, 702 Web methods asmx file extension for, 564 invoking, 537–538 wrapper methods as, 564 1519 bindex.indd 1519 8/21/07 2:13:56 AM Web pages Web pages MasterDetailControl server control used in, 916–921 visiting partial-page-rendering enabled Web page, 971 Web service bridges client control component See AspNetAjaxAmazonSearch client control defined, 564 demystified, 591–593 HtmlGenerator client component See HtmlGenerator client control HtmlGenerator server component See HtmlGeneratorScriptControl server control overview of, 781 server control component See AmazonSearchScriptControl server control steps in using, 564–565 using bridge-enabled script server components, 811–812 wrapper methods and, 570 Web services building, 511–512 calling custom methods, 564–570 calling page methods, 561–563 client-side code for invoking server side methods, 570 consuming via JSON messages, 535 example of page exchanging SOAP messages with Web service, 525–528 example page using WebServiceError class, 557–561 HandlerWrapper, 582–583 obtaining data records from, 1417–1422 overview, 511 proxy classes associated with, 600–605 RestHandler, 577–582 RestHandlerFactory, 574–577 ScriptHandlerFactory, 571–574 ScriptModule, 583–591 SOAP messages See SOAP messages transformers See transformers using replicas of HTTP handler factories, 593–595 WebServiceError class, 553–556 WebServiceProxy class See WebServiceProxy class wrapping a custom class, 591–592 WSDL documents See WSDL documents Web services, Amazon E-commerce ItemSearch, 774–781 overview of, 773–774 web.config file, 573–574, 583–584 WebControl class, 896 WebRequest class abort method, 506–508 body of request, 459 in client-server communication example, 492 client-side code for downloading WSDL documents and loading into XMLDOM documents, 524 completed event, 461–462 completion of Web request, 494 constructor, 457–458 example page using, 487–490 executor methods, 460 headers, 460 HTTP verb, 458–459 invoking Web requests, 462–463 overview, 457 submitCallback function instantiating, 492 target URL, 458 timeout methods, 459 WebServiceProxy class encapsulating logic of, 535 WebRequest object, 1172–1176 WebRequestExecutor class abort method, 467 client-side code for downloading WSDL documents and loading into XMLDOM documents, 524 completion of Web requests, 494 constructor, 463 example page using, 497–498 executeRequest method, 467 get_aborted method, 465 getAllResponseHeaders method, 468 get_object method, 466–467 get_responseAvailable method, 464–465 get_responseData method, 465 getResponseHeader method, 467–468 get_started method, 464 get_statusCode method, 466 get_statusText method, 466 get_timeOut method, 465 get_xml method, 466 overview, 463 referencing WebRequest object, 463–464 requestCompleted event, 493 1520 bindex.indd 1520 8/21/07 2:13:56 AM WebRequestExecutor object, 1172–1176 WebRequestManager class, 498–502 client-side code for downloading WSDL documents and loading into XMLDOM documents, 524 constructor, 468–469 default executor type, 469 default timeout, 469 events, 470–471 executing Web request, 471–473 NetworkRequestEventArgs class, 473–474 overview, 468 single instance of, 498–502 WebServiceProxy class encapsulating logic of, 535 WebServiceError class code listing, 555 constructor, 555–556 example page using, 557–561 onComplete method and, 553–554 WebServiceHandlerFactory, 572–573 WebServiceProxy class add function for instantiating, 552–553 constructor, 535 _createQueryString method of WebRequest class, 544–545 _createUrl method of WebRequest class, 543 default failed callback methods, 536 default succeeded callback methods, 536 example page using, 549–551 _invoke method, 537–538 invoke method, 539–542 onComplete method, 545–549 overview, 535 path methods, 537 proxy classes deriving from, 602 timeout methods, 535–536 Web service used by example page, 551–552 width property, Image client controls, 299 Window class, client-server communication, 509 wrapper methods choices for placing, 564 Web service bridges and, 570 Web service wrapping a custom class, 591–592 WriteXml method, IXmlSerializable interface, 839, 842 WSDL documents, 512–518 See also SOAP messages argument names, types, and order, 514–515 client-side code and, 524 Index XmlBridgeTransformer communication protocol determined by, 519 communication protocol used by method, 516–517 element, 514 describing XML Web service, 513–514 information about XML Web service methods, 512–513 method, parameters, and return value of SOAP messages determined by, 522 request and response messages in method, 515–516 return value types and order, 515 site for method access, 517–518 specifying method class, 518 X x and y coordinates DomElement getBounds method, 175–176 DomElement getLocation method, 171 DomElement setLocation method, 172–175 XHTML, 1–2 XML (eXtensible Markup Language) AJAX-enabled components and, code listing, 16–18 deserialize function, 18–20 serialize and deserialize functions in, 16 transformer See XmlBridgeTransformer XML documents bridge element, 565–567 SOAP messages and, 518 user controls, partial-rendering enabled, 953–957 XML namespace _getTagType method, 1279–1281 _processNamespaceURI method, 1281–1283 XML Schema, serializing See XmlSerializer XML Web services SOAP messages See SOAP messages WSDL documents See WSDL documents XmlAttribute, metadata attribute, 833 XmlBridgeTransformer, 823–848 code listing, 823–824 example (HtmlGenerator2 client control), 826–827 overview of, 823 provided by ASP.NET AJAX framework, 818 serializing XML Schema correctly See XmlSerializer Transform method, 824–825 1521 bindex.indd 1521 8/21/07 2:13:57 AM XmlDataSource control XmlDataSource control, 954–957 XMLDOM class, 474–475, 524 XMLDOM document, 1274 XMLHttpExecutor class, 475–487 abort method, 485–487 _clearTimer method, 477 constructor, 475–476 default executor type, 469 executeRequest method, 479–482 get_aborted method, 479 getAllResponseHeaders method, 483 get_responseAvailable method, 479 get_responseData method, 483 getResponseHeader method, 482–483 get_started method, 479 get_statusCode method, 484 get_statusText method, 484 get_timeOut method, 478 get_xml method, 484–485 _onReadyStateChange method, 476–477 _onTimeout method, 477–478 overview, 475 page using WebRequestExecutor, 497–498 WebServiceProxy class encapsulating logic of, 535 XMLHttpRequest class, 4–15 characteristics of AJAX-enabled components, in client-server communication, 474 code listing, 6–10 deserialize function, 14–15 instantiation process, methods and properties, 5–6 serialize function, 12–14 submitCallback function, 11–12 XMLHttpRequest methods and properties, AJAX, 5–6 XmlSchemaProvider, 839 xml-script, 1272–1315 binding in See binding _getDefaultNamespaces method, 1283 _getTagType method, 1279–1281 initHandler method, 1273 initializeObject method, 1287–1315 MarkupContext class, 1267–1272 overview of, 1267 parseFromMarkup method, 1284–1287 parseNode method, 1278–1279 parseNodes method, 1276–1277 processDocument method, 1273–1275 processDocumentScripts method, 1275–1276 _processNamespaceURI method, 1281–1283 starting script, 1272–1273 XmlSerializer, 828–848 code listing for AmazonService2 class, 829–832 IXmlSerializable interface as approach to communication with, 839–848 methods for communicating with, 828 Results and Result classes as approach to communication with, 832–839 XPath DetailsView control and, 959 hierarchical or location path for identifying tree nodes, 955 xsd.exe utility, 837 XsltBridgeTransformer, 848–855 AmazonSearch4.asbx code listing, 851 AmazonSearch4.aspx code listing, 855 AmazonService4 class, 852–854 code listing, 850–851 overview of, 840 Y y coordinates See x and y coordinates 1522 bindex.indd 1522 8/21/07 2:13:57 AM badvert.indd 1523 8/21/07 9:49:12 AM badvert.indd 1524 8/21/07 9:49:12 AM ... Welcome to ASP.NET AJAX Programmer’s Reference with ASP.NET 2.0 or ASP.NET 3.5 The ASP.NET AJAX framework consists of two frameworks: the ASP.NET AJAX client-side framework and the ASP.NET AJAX server-side... AM ASP.NET AJAX Programmer’s Reference with ASP NET 2.0 or ASP.NET 3.5 ffirs.indd iii 8/25/07 2:41:00 AM ffirs.indd iv 8/25/07 2:41:00 AM ASP.NET AJAX Programmer’s Reference with ASP.NET 2.0 or. .. The ASP.NET AJAX server-side framework extends the ASP.NET Framework to provide server-side support for Ajax- enabled Web applications The ASP.NET AJAX client-side and server-side frameworks work