开发者

How does one call client side and server side code for each selected node in treeview?

For each node in treeview, its NavigateUrl is s开发者_如何学JAVAet 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?


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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜