Sunday, September 21, 2008

Change the asynchronous timeout of the Callback Manager used by the WebAsyncRefreshPanel and WebTab

To change the default timeout, you need to modify the _timeLimit property on the Callback Manager object on the client side. This can be accomplished using the following line of code:

In Javascript:

ig_shared.getCBManager()._timeLimit = ;

Replace with the length of time (in milliseconds), you wish to change the timeout to.

Setting the timeout for the WebAsyncRefreshPanel in the InitializePanel client-side event:

In JavaScript:

function WebAsyncRefreshPanel1_InitializePanel(oPanel){
ig_shared.getCBManager()._timeLimit = 40000;
}


Setting the timeout for the WebTab in the InitializeTabs client-side event:

In Javascript:

function UltraWebTab1_InitializeTabs(oWebTab){
ig_shared.getCBManager()._timeLimit = 40000;
}
Reminder: the above code will not work in the release build of NetAdvantage 2006 Volume 3 as this functionality was added later on in a hot fix.

State of new nodes is lost when using ManualSmartCallbacks for WebTree

In NetAdvantage 2006 Volume 1, WebTree introduced two additional modes of performing load-on-demand operations: ManualSmartCallbacks and AutomaticSmartCallbacks. The purpose of these values is to provide similar functionality to their Manual and Automatic counterpart settings, but utilizing the out-of-band callback capabilities of SmartCallbacks (a.k.a. AJAX requests).

For the AutomaticSmartCallbacks setting, the functionality is quite similar to the Automatic setting where a datasource is utilized to rebind the tree on each callback to read in the appropriate nodes. The state of the tree is also maintained automatically by the tree, so that it knows which nodes have been expanded and which have not.

For ManualSmartCallbacks, however, the job of maintaining the state of the nodes falls to the application. The only value that is tracked by WebTree is the DataPath property of the node. This value is sent back to the server when a node is expanded on the client and is available on the e.Node.DataPath property within the DemandLoad event on the server. Thus, every node that is populated with the ShowExpand property set to true should also have the DataPath property set to a string that can be used to retrieve the children of the node when the user clicks to expand it. This is correct behavior.

When AutomaticSmartCallbacks are being used, WebTree sets the DataPath property to the XPath expression that corresponds to the node within the XmlDataSource.

In general, if data can be fetched from an XmlDataSource using CLR 2.0, then using AutomaticSmartCallbacks is easier and more functional than using ManualSmartCallbacks.

The limitations of ManualSmartCallbacks may render it unsuitable for use in situations where the full page must be posted back to the server and the full state of all expanded nodes needs to be recreated by the application. In such cases, the preexisting value of Manual should continue to be used. With LoadOnDemand.Manual set and ViewState enabled, the WebTree is able to reconstruct the node structure on a full postback of the page.

If you are using NetAdvantage for .NET 2006 Volume 3 or later, you can still achieve AJAX functionality without incurring the limitations of ManualSmartCallbacks. Place your WebTree inside a WebAsyncRefreshPanel (or "WARP"), and set the LoadOnDemand property to Manual instead. This gives the flexibility of Manual load-on-demand, including the persisting of the tree's node structure, while providing AJAX functionality via the WARP.

Redirecting browser to a different page during an asynchronous callback of the WebAsyncRefreshPanel

When not processing an asynchronous callback through the WebAsyncRefreshPanel, the following code will tell the browser to navigate to a different page:

In C#:

Response.Redirect("NewPage.aspx", true);

LiteralControl c = new LiteralControl("");
this.WebAsyncRefreshPanel1.Controls.Add(c);

change the image of a WebAsyncRefreshPanel's Progress Indicator

To change the WebAsyncRefreshPanel’s Progress Indicator image, you will need to handle the control’s client side InitializePanel event. In this event, you will then need to get a reference to the progress indicator itself using the WebAsyncRefreshPanel’s getProgressIndicator() method. Once you have a reference to the progress indicator, you can use its setImageUrl() method to change the image you want to use.

In JavaScript:


function WebRefreshPanel2_InitializePanel(oPanel)
{
oPanel.getProgressIndicator().setImageUrl("");
}

hide the Progress Indicator for the WebAsyncRefreshPanel and WebTab

Note that since the WebTab and WebAsyncRefreshPanel use the same CallbackManager, a single progress indicator is shared by all WebAsyncRefreshPanels and WebTabs on a page.

Step-By-Step Example

For the WebAsyncRefreshPanel, the following line of JavaScript placed within the client-side InitializePanel event handler will hide the progress indicator.
In Javascript:

oPanel.getProgressIndicator().setTemplate(" ");

For the WebTab, the following line of JavaScript placed within the client-side InitializeTabs event handler will hide the progress indicator.
In Javascript:

oWebTab.getProgressIndicator().setTemplate(" ");