ASTreeView – Perform PostBack while deleting nodes

by Weijie JIN on

How to do a postback after a node being deleted?

Here’s the steps:

1. Set the OnNodeDeletedScript property of ASTreeView.


2. Add a hidden button and a textbox(both are server side control) to the page:

<div style="display:none;">
	<asp:Button ID="btnPostBackTrigger" runat="server" OnClick="btnPostBackTrigger_Click" />
	<asp:TextBox ID="txtIDContainer" runat="server"></asp:TextBox>

3. Implement the deletedHandler javascript method:

<script type="text/javascript">
	//parameter must be "val"
	function deletedHandler( val ){
		document.getElementById( "<%=txtIDContainer.ClientID %>" ).value = val;
		document.getElementById( "<%=btnPostBackTrigger.ClientID %>" ).click();

4. Implement the Server Side method of postback:

protected void btnPostBackTrigger_Click( object sender, EventArgs e )
	string deletedNodeId = this.txtIDContainer.Text;

	//do anything you want on server side.
	//for example, update another tree using the deletedNodeId

That’s it.

  • tejas

    hey while i m deleting node , some times its thorugs errors from javascipts. which is not supported to me, my code is on server side. please suggestion any quick solution

  • tejas

    and how to set postback while once node added successfully, and bind properly, but while i click on node, which takes me on selected node change event but its not working, so please suggest me any possible solution

  • tejas

    and How to add node with some ohter text value, ex: Add node prompt for text and i want to put value within it,in another textbox or on another textbox, so can we this possible with this treeview ??

  • Peter Huang


    I can’t get any data when I try to delete a node.

    the code like this.
    //parameter must be “val”
    function deletedHandler( val ){
    document.getElementById(”).value = val;

    I guess maybe that is because I have two ASTreeView controls in one page,
    please help me to check, thanks.


Previous post:

Next post: