Synchronizing ViewState
One of the things that is integral to ASP.NET is the ViewState. The ViewState is encoded data that saves important data about a page in a special hidden form element called __ViewState. This data includes values that are bound to a grid, drop-down list, or other form element. This information is used to keep the data consistent between page postbacks as well as allow for change events to occur on this page. The problem with this is that with ASP.NET AJAX calls can be made to the server and...
Invalid Postback or Callback Argument
1. There is a server-side drop-down list box. 2. Another form element makes an ASP.NET AJAX call and brings back data. 3. This data is then populated into the drop-down list box. 4. A user then clicks a button, which results in a server-side button click event being called. The result of these four steps is the exception shown in Figure 4-8. This exception occurs because the ASP.NET runtime did not know about this new value in the ASP.NET drop-down list box. This is the first problem that...
Working with the WebConfig File
In the Program Files Microsoft ASP.NET ASP.NET 2.0 AJAX Extensions v1.x folder you'll find a web.config file, as shown in the following code. This file contains all the settings the ASP.NET AJAX library could possibly require from an ASP.NET AJAX-enabled web site. Depending on which ASP.NET AJAX features your application uses, it's likely that your web application web.config file won't need every one of these settings. lt xml version 1.0 gt lt configuration gt lt configSections gt lt...
Advantages and Disadvantages of Using the AJAX Control Toolkit
So, why wouldn't you simply use the AJAX Control Toolkit in all cases when building a custom extender The simple answer is you can. The disadvantages to using the Toolkit are minimal, but still need to be considered. First, there is a dependency on the AjaxControlToolkit.dll assembly that forms the Toolkit. This needs to be packaged and deployed with your application. Second, some extra script file dependencies, which need to be downloaded at runtime, are used by the Toolkit. This follows the...
The Sys Namespace
The Sys namespace is the root namespace for the Microsoft AJAX Library and contains all fundamental classes and base classes that are built on top of the new JavaScript Base Type Extensions mentioned in the previous chapter. These classes provide a JavaScript framework that feels very comfortable for people who use the .NET framework already, particularly C because they use a very similar syntax. Some of the popular classes are Sys.Debug and Sys.StringBuilder along with the Sys.WebService and...
Using Microsoft ASPNET AJAX
Now that you have the foundation set for granting access to a known user to your web site, you can begin using the Microsoft ASP.NET 2.0 framework to provide membership and profile support. The ASP.NET application services integration is divided into two sections the authentication service or membership support and the profile service. The authentication service provides AJAX features to help you create client-side login and logout screens. The profile service allows you to read and write user...
Using User Context
As stated earlier in the chapter, user context is an instance of any JavaScript primitive type, object, or array that is passed from a calling function to a callback function. Until now you have seen only placeholders for the userContext argument in the examples showing you how to use the functions to interface with ASP.NET application services. The following example shows you how to use the userContext argument in your pages. The following implementation uses a profile read operation for...
Asynchronous vs Synchronous Postbacks
ASP.NET 1.x is considered to be synchronous. From a user's perspective, synchronous means that he or she clicks a submit button and the page stops responding while the browser makes a round trip to the server for a new version of the entire page and then redraws it element by element. Displaying custom status bars or animated .gifs is usually not feasible during this postback process. This process happens even in situations where only a single element on the page needs updating. This technique...
Exploring the Microsoft AJAX Library
The Microsoft AJAX Library effectively extends JavaScript with capabilities that it never had before. For example, when creating client-side script you'll now have new object-oriented features at your disposal such as classes, inheritance, interfaces, namespaces, enumerations, and reflection. See Chapter 8 for additional JavaScript enhancements. JavaScript has also been extended with types familiar to C developers, such as StringBuilders and Timers. Even existing JavaScript types such as...
Try It Out Adding AutoCompleteExtender
After the Control Toolkit is installed, adding the AutoCompleteExtender to the Search text box in the site.master page is fairly straightforward 1. Locate the txtSearch control in site.master, and add the extender control lt asp TextBox ID txtSearch lt ajaxToolkit AutoCompleteExtender runat server ID autoComplete1 TargetControlID txtSearch MinimumPrefixLength 2 CompletionInterval 1000 EnableCaching true CompletionSetCount 12 gt lt asp ImageButton ID btnSearch runat server SkinID doSearch...


