|
Basic and fast set up for TreeView events
|
| | |
Step 1: Page set up
By default, TreeView needs two pages to be able to process events:
1. Default.aspx – This is where your tree is displayed. You can name this page any way you like.
2. TreeEvents.aspx – This page will process all your tree events.
Obout TreeView uses AJAXPage to notify the server of its actions. It does so by posting event details to TreeEvents.aspx page.
Suite download includes TreeEvents.aspx file that contains all event handlers for your convenience. There is also a fully functional example, called All Events, that this tutorial is based on.
| | |
Step 2: Add AJAXPage
Add AJAXPage control to Default.aspx and TreeEvents.aspx by inheriting the pages from AJAXPage
Directly on aspx page:
<%@ Page Language="C#" Inherits="OboutInc.oboutAJAXPage" %>
In code behind:
C#
public class PageName : OboutInc.oboutAJAXPage { ... }
VB.NET
Public Class PageName Inherits OboutInc.oboutAJAXPage { ... }
| | |
Step 3: Listing events
You need to tell TreeView about all events that you will be handling. To do this you must list them in EventList property.
oTree.EventList = "OnNodeSelect,OnNodeDrop,OnAddNode";
The following events are available:
- OnNodeSelect
- OnNodeEdit
- OnNodeDrop
- OnAddNode
- OnRemoveNode
- OnNodeExpand
- OnNodeCollapse
- OnBeforeNodeEdit
- OnBeforeAddNode
- OnBeforeRemoveNode
- OnBeforeDrop
- OnMoveNodeUp
- OnMoveNodeDown
| | |
Step 4: Defining event handlers
For each event that you listed in step 3, you must define a public server side function in TreeEvents.aspx
For example, here is a function for OnNodeEdit in C#
public string OnNodeEdit(string id, string text, string prevText) {
//update database
return "Node successfully updated";
}
Each handler has different amount of arguments, depending on the event.
See list of handlers and their arguments.
| | |
That's it! Now on each tree event, a corresponding server side event handler will get executed in TreeEvents.aspx
We strongly recommend to check All Events example in the TreeView section of suite examples.
| | |
| "You guys have the best controls around." |
Neal Miller |
| Miller Systems, Inc. |
| | |
|