Chapter 1. Introducing ASP.NET AJAX
Listing 1.1. Instantiating the XMLHttpRequest object
Listing 1.3. Sending an asynchronous request
Listing 1.5. Using the XMLHttpRequest control to asynchronously retrieve data
Listing 1.6. XML-Script: a declarative alternative for developing Ajax-enabled pages
Listing 1.7. A simple class that returns the number of employees in a department
Listing 1.8. Default page created by the ASP.NET AJAX-Enabled Web Site template
Listing 1.9. Setting AutoPostBack to true causes a postback and invokes the server-side code.
Listing 1.10. Retrieve the employee count and update the UI when a new department has been selected.
Listing 1.11. UpdatePanel control, designating page regions that can be updated dynamically
Listing 1.12. Adding a Sleep command to test the UpdateProgress control.
Listing 1.13. Adding attributes to the class and methods
Listing 1.14. Adding a service reference, which will generate the JavaScript proxies
Listing 1.15. Markup portion of the client-centric solution
Listing 1.16. The script portion of the employee lookup application
Chapter 2. First steps with the Microsoft Ajax Library
Listing 2.1. Code for testing the client-page lifecycle
Listing 2.2. Handling the init event of Sys.Application
Listing 2.3. A text box that accepts only letters
Listing 2.4. Using a client delegate to handle a DOM event
Listing 2.5. Using a callback to handle a DOM event
Listing 2.6. Example using the Sys.StringBuilder class
Listing 2.7. Some of the new methods added to the Array object
Listing 2.8. Using the Sys.Browser object to perform browser detection
Listing 2.9. A custom error type created with the Error.create method
Chapter 3. JavaScript for Ajax developers
Listing 3.1. Creating a closure by returning an inner function
Listing 3.2. The constructor for a Cat object
Listing 3.3. Expanding the prototype object to define an object’s initial structure
Listing 3.4. A Pet class defined with the Microsoft Ajax Library
Listing 3.5. The Pet class with two properties
Listing 3.6. Declaring a class in a namespace
Listing 3.7. An example of prototype-based inheritance in JavaScript
Listing 3.8. Deriving from a base class with the Microsoft Ajax Library
Listing 3.9. How to pass arguments to the constructor of the base class
Listing 3.10. Calling the implementation of a method defined in the base class
Listing 3.11. Declaring the IComparable interface
Listing 3.12. Implementing the IComparable interface
Listing 3.13. A Size enumeration
Listing 3.14. A FileAccess enumeration that uses flags
Chapter 4. Exploring the Ajax server extensions
Listing 4.1. An example of how a script is deployed with the ScriptManager
Listing 4.2. A ScriptReference, which registers files for deployment to a web page
Listing 4.3. A ServiceReference, which provides a gateway to the service from JavaScript
Listing 4.4. Using the ScriptManagerProxy control in a master-page scenario
Listing 4.5. Selecting an item from the music genre list generates a postback to the server.
Listing 4.6. Selecting an item in the list updates the Repeater’s data source.
Listing 4.7. Dynamically updating regions during asynchronous postbacks
Listing 4.8. During an asynchronous postback, the page goes through the normal page lifecycle.
Listing 4.9. Displaying the UpdateProgress control when the UpdatePanel’s contents are being updated
Listing 4.10. The Timer runs in the client and invokes a postback at each interval.
Listing 4.11. The Tick event, which calls the private UpdateGenre method
Listing 4.12. Registering the Timer control’s Tick event to ensure asynchronous postbacks
Listing 4.13. Throwing an exception to see how the page handles it
Listing 4.14. Raising the AsyncPostBackError event before the dialog is displayed to the user
Listing 4.15. The AllowCustomErrorsRedirect property overrides the web.config settings.
Chapter 5. Making asynchronous network calls
Listing 5.1. Configuring a web service for client-script interaction with a few attributes
Listing 5.2. Adding a service reference to the ScriptManager control
Listing 5.3. Text box and button to provide an interface for passing parameters to the service
Listing 5.4. Calling a web method from JavaScript
Listing 5.5. Implementation of a custom Beverage class
Listing 5.6. Implementation for the GetDeals method
Listing 5.7. Calling and handling from JavaScript a web method that returns a complex type
Listing 5.8. The Employee class: another complex type defined on the server
Listing 5.9. Adding support for the Employee class on the client using GenerateScriptType
Listing 5.10. Enabling HTTP GET by updating the ScriptMethod attribute and UseHttpGet property
Listing 5.11. Instantiate the Employee class on the client, and pass it to a PageMethod.
Listing 5.12. A simple HTTP request for the contents of another file on the server
Listing 5.13. Modified version of the onRequestComplete function to handle HTTP errors
Listing 5.14. A reusable error-checking routine that extends the WebRequestExecutor object
Listing 5.15. GeocodeService that acts as the proxy to the Yahoo! Geocode APIs
Listing 5.16. Location class for defining coordinates on a Virtual Earth map
Listing 5.17. Implementation details for communicating with the Yahoo! APIs
Listing 5.18. Client code for the geographical mashup
Listing 5.19. The bridge file provides a roadmap or gateway to the remote service.
Listing 5.20. XPathBridgeTransformer, which lets you query the response to an object
Listing 5.21. Contents of the Flickr bridge application
Listing 5.22. Using the authentication service from JavaScript to validate a user’s credentials
Listing 5.23. Structure of the login method in the authentication service
Listing 5.24. Adding properties to the users profile
Listing 5.25. Load method of the profile service, which retrieves a user’s settings
Listing 5.26. Save function, which updates a user’s profile information
Chapter 6. Partial-page rendering with UpdatePanels
Listing 6.1. Markup for the home page before adding the UpdatePanel
Listing 6.3. Declaratively adding controls to the UpdatePanel
Listing 6.4. Adding a control to the UpdatePanel programmatically
Listing 6.5. Setting the UpdateMode property to Conditional
Listing 6.6. Rendering the UpdatePanel’s contents as a <div> or <span> tag
Listing 6.7. Programmatically registering a trigger with an UpdatePanel
Listing 6.8. Controls outside the UpdatePanel’s declaration invoking asynchronous postbacks
Listing 6.9. Declaring a child control as a postback trigger
Listing 6.10. Registering a child control as a control that raises a normal postback
Listing 6.11. Setting ChildrenAsTriggers to false so as not to initialize triggers
Listing 6.12. Manually updating a page by calling its Update method
Listing 6.13. Repeating an UpdatePanel
Listing 6.14. Updating the stock price
Listing 6.15. Nesting UpdatePanel controls
Listing 6.16. The application contains a GridView and SqlDataSource configured to AdventureWorks.
Listing 6.17. Applying a filter expression to the data source and updating the results
Listing 6.18. Wrapping the GridView and SqlDataSource within an UpdatePanel
Listing 6.19. Removing the Filter button and adding the event handler for the TextChanged event
Listing 6.20. Hooking into the keydown event to launch a postback on the server
Chapter 7. Under the hood of the UpdatePanel
Listing 7.1. Using the IsInAsyncPostBack property to identify asynchronous postbacks
Listing 7.2. Configuring the page for partial updates with _initialize and _updateControls
Listing 7.3. The general layout for the client-side event viewer
Listing 7.5. Querying the event arguments to determine whether the postback is asynchronous
Listing 7.6. Adding event handlers for events raised by the PageRequestManager
Listing 7.7. Adding an UpdatePanel control and child controls to invoke asynchronous postbacks
Listing 7.8. Clicking the Abort button aborts the postback.
Listing 7.9. Adding a new button to assign precedence to a postback
Listing 7.10. Aborting and canceling requests during partial updates
Listing 7.11. Show and hide a visual prompt to the user during asychronous operations.
Listing 7.12. Determine which panels are being rendered as a result of a partial postback.
Listing 7.13. Throw an unfortunate, but polite, error.
Listing 7.14. Handling an error from the client
Listing 7.15. Removing the parent node to speed up the rending process
Listing 7.16. Registering script with the ScriptManager ensures that it’s UpdatePanel-compatible.
Listing 7.17. Exchange existing validators with the new set while preserving the tag.
Chapter 8. ASP.NET AJAX client components
Listing 8.1. Code for the trivial component
Listing 8.2. Code for testing the trivial component
Listing 8.3. Property-change notification applied to a property of a client class
Listing 8.4. Subscribing to the propertyChanged event
Listing 8.5. The simplest behavior is an empty behavior.
Listing 8.6. Code for the FormattingBehavior class
Listing 8.7. Simulating the in-place edit functionality with the FormattingBehavior
Listing 8.8. The simplest control is an empty control.
Listing 8.9. keypress eventCode for the Samples.TextBox control
Listing 8.10. Code for testing the Samples.TextBox control
Listing 8.11. HTML code for the UI of the PhotoGallery control
Listing 8.12. Code for the PhotoGallery class’s constructor
Listing 8.13. Prototype of the PhotoGallery control
Listing 8.14. Creating an instance of the PhotoGallery control
Chapter 9. Building Ajax-enabled controls
Listing 9.1. Example $create statement used to create an instance of the PhotoGallery control
Listing 9.2. A script descriptor for configuring an instance of the PhotoGallery control
Listing 9.3. Code for the FormattingExtender class
Listing 9.4. How to extend an ASP.NET web control declaratively
Listing 9.5. Extending an ASP.NET web control programmatically
Listing 9.6. Overriding the OnPreRender method to register the script control
Listing 9.7. Overriding the Render method to register the script descriptors
Chapter 10. Developing with the Ajax Control Toolkit
Listing 10.1. Code for the ASP.NET TextBox with an associated AutoCompleteExtender control
Listing 10.2. Code for the CountryService web service
Listing 10.3. XML file containing the list of countries
Listing 10.4. Code for the GetCountriesFromXml method
Listing 10.5. Using the BehaviorID property with the slider extender
Listing 10.6. Constructor of the TextChangedBehavior class
Listing 10.7. Implementing a simple timer in JavaScript
Listing 10.8. Firing a DOM event programmatically
Listing 10.9. Complete code for the TextChangedExtender class
Listing 10.10. Example usage of the TextChangedExtender
Listing 10.11. Skeleton of the animation extender
Listing 10.12. Animating a div element with the AnimationExtender control
Listing 10.13. The yellow spotlight pattern applied to an UpdatePanel
Chapter 11. XML Script
Listing 11.1. Enabling XML Script in an ASP.NET page
Listing 11.2. Code for the “Hello XML Script!” example
Listing 11.3. Using the Label and Button controls in XML Script
Listing 11.4. Type descriptor exposed by the Sys.Preview.UI.Button class
Listing 11.5. Using the SetProperty action to handle an event
Listing 11.6. Code for the DateTimeService class
Listing 11.7. Making a declarative Web Service call
Listing 11.8. Code for the AlertAction class
Listing 11.9. Using the Alert action in XML Script
Listing 11.10. Code for the ConfirmPostBack action
Listing 11.11. Using the ConfirmPostBack action in XML Script
Listing 11.12. Binding between a text box and a label
Listing 11.13. A stand-alone binding
Listing 11.14. A counter built with XML Script
Listing 11.15. A custom transformer that simulates a simple scroll effect
Chapter 12. Dragging and dropping
Listing 12.1. Enabling drag and drop in an ASP.NET page
Listing 12.2. Code for the BookItem control, which represents a draggable item
Listing 12.3. IDragSource interface implementation
Listing 12.4. Code for the CartZone class, which represents a drop zone
Listing 12.5. IDropTarget interface implementation
Listing 12.6. ASP.NET page for testing the drag-and-drop example
Listing 12.7. The XML file used as the data store
Listing 12.8. Code for the ShoppingCart.ascx file
Listing 12.9. Storing shopping-cart articles in a Session variable
Listing 12.10. IShoppingCart interface implementation
Listing 12.11. ShoppingCart: IScriptControl interface implementation
Listing 12.12. Markup code for the BooksCatalog user control
Listing 12.13. Handling the ItemCommand event
Listing 12.14. BooksCatalog: IScriptControl interface implementation
Listing 12.15. Code for the Default.aspx page, which hosts the Ajax-enabled controls
Chapter 13. Implementing common Ajax patterns
Listing 13.1. Using anonymous functions to declare methods of an object
Listing 13.2. A debug version of the Person class
Listing 13.3. Adding XML comments to a JavaScript client class
Listing 13.4. Validating the parameters passed to a JavaScript function
Listing 13.5. A StringCollection object in JavaScript
Listing 13.6. Validating references in the initialization code
Listing 13.7. A simple property declared in a client class
Listing 13.8. Code for automating the creation of a simple property
Listing 13.9. Creating client properties with the createProperty method
Listing 13.10. Automating the creation of a client event
Listing 13.11. A simple RSS aggregator that uses the UpdatePanel to update the page
Listing 13.12. Code-behind solution for a simple RSS reader application
Listing 13.13. Using the AddHistoryPoint method
Listing 13.14. Retrieving the state of the page and restoring it to completes the logical navigation
Listing 13.15. Managing the History control and the Navigate event from JavaScript
Listing 13.16. Retrieving and formatting the state string to get a unique link to a page
Listing 13.17. Code for the ProductsService Web Service
Listing 13.18. Code for the Product class
Listing 13.19. Templates for the ListView control
Listing 13.20. XML Script code for the declarative data-binding example
Listing 13.21. Imperative code used in the declarative data-binding example
Listing 13.22. Static HTML for the declarative widgets example
Listing 13.23. Declarative XML Script code for the widgets example
3.143.241.133