views:

351

answers:

4

Hello!

I'm developing an ASP.NET application and I'm trying to do the following:

I'm going to have only one ASPX page splitted into two columns. On the left column is going to be a TreeView, and on the right column is going to be something to edit treeview's nodes.

When the user can select a treeview's node to edit on the right column. Depending on the node's depth fields on right column will vary.

I wondering to use ASCX controls and load on right column dinamically using AJAX, for example. Is there a better choice? Can I do that?

Any advice?

EDIT:

I don't want to reload the entire page when the user wants to edit a treeview's node. Maybe I'm going to need an UpdatePanel on the right column, isn't it?

Thank you.

+3  A: 

In general, yes this can be done and is not so hard to accomplish with the different .NET ajax frameworks.

It is difficult to suggest a "better choice" because that depends on how you build your application and the different requirements for it.

Oded
Will I need an Updatepanel on the right column?
VansFannel
+2  A: 

Wrap your treeview inside an UpdatePanel, and add the following code in the code-behind. (assuming your right panel is called 'PanelOnTheRight', and you have a usercontrol 'MyEditControl' with a property 'IdToEdit').

void MyTreeView_SelectedNodeChanged(Object sender, EventArgs e)
{
    PanelOnTheRight.Controls.Clear();

    MyEditControl editControl = LoadControl("~/usercontrols/mycontrol.ascx");
    editControl.IdToEdit = ((TreeView)sender).SelectedNode.Value;

    PanelOnTheRight.Controls.Add(editControl);
}
Jan Jongboom
Will I need an Updatepanel on the right column?
VansFannel
Yes, you'll need to wrap every section you want to update in an updatepanel.
Jan Jongboom
I've followed your answer but when I click on a treeview's node the loaded control disappears of the right column. What's happening?
VansFannel
I've found this article that solves my problem: http://msdn.microsoft.com/en-us/magazine/cc748662.aspx#id0070065
VansFannel
A: 

You can use Page.LoadControl method to load user controls. But I am not sure whether it works with Ajax

Anuraj