OnClientNodePopulationFailed
The OnClientNodePopulationFailed client-side event occurs when:
-
Child nodes are loaded on-demand.
-
The parent node ExpandMode property is ServerSideCallback or WebService.
-
An exception occurs while loading.
The event handler receives parameters:
-
The TreeView instance that fired the event.
-
Event arguments with functions:
-
get_node() retrieves a reference to the parent node.
-
get_errorMessage() retrieves the exception message text.
-
set_cancel() - call this function to specify whether the event should be canceled (true) or not (false). Canceling of the event will prevent the exception from propagating.
-
get_domEvent() retrieves a DOM event object.
In the example below an exception is raised in the server-side NodeExpand event handler
<telerik:RadTreeView RenderMode="Lightweight" ID="RadTreeView1" runat="server" OnClientNodePopulationFailed="ClientNodePopulationFailed"
OnNodeExpand="RadTreeView1_NodeExpand">
<Nodes>
<telerik:RadTreeNode runat="server" ExpandMode="ClientSide" Text="Search" ImageUrl="~/images/search.ico"
Expanded="True" Value="1">
<Nodes>
<telerik:RadTreeNode runat="server" ExpandMode="ServerSideCallBack" Text="Recent Searches">
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" ExpandMode="ServerSideCallBack" Text="Network Locations">
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeView>
Note that the custom alert will appear on remote clients, only if the customErrors mode is set to Off in the web.config:
The server NodeExpand event handler for the RadTreeView defined above:
protected void RadTreeView1_NodeExpand(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
{
throw new ApplicationException("An error occurred while attempting to populate " + e.Node.Text);
}