views:

132

answers:

1

For each node in treeview, its NavigateUrl is set to call Client Side function which loads new page (page 2). While doing this, SelectedNodeChanged event for treeview doesn't fire (page 1).

[Server Side]

 node.NavigateUrl = "javascript:RefreshWorkspaceHome();";

RefreshWorkspaceHome(): either load new page or call doPostBack to execute some server side code for page 2. Problem now that SelectedNodeChanged event doesn't fire for page 1.

Any idea?

A: 

If a node has a navigate URL, then when a user clicks on it, the web browser will navigate to the specified URL, thus bypassing the post back that would have happened instead. It does this because the node is simply rendered as a hyper link in the HTML (an "a tag"). What you could do instead is remove the NavigateUrl property from the nodes and do the redirect to the new page on the server. Here's an example of what your page 1's code-behind could look like:

// This is the event handler for the TreeView's SelectedNodeChanged event
protected void onSelectedNodeChanged(object sender, EventArgs e)
{
    // Do server-side processing first
    // ...

    // Now do the redirect to page 2
    Response.Redirect("page2.aspx");
}
Jacob