使用 AJAX 动态加载 ASCX 控件
我正在开发一个 ASP.NET 应用程序,并尝试执行以下操作:
我将只有一个 ASPX 页面分成两列。左列将是 TreeView,右列将是用于编辑 TreeView 节点的内容。
当用户可以在右列上选择要编辑的树视图的节点时。根据节点的深度,右列上的字段会有所不同。
例如,我想使用 ASCX 控件并使用 AJAX 动态加载右列。还有更好的选择吗?我可以这样做吗?
编辑:
当用户想要编辑树视图的节点时,我不想重新加载整个页面。也许我需要在右列上有一个 UpdatePanel,不是吗?
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 dynamically using AJAX, for example. Is there a better choice? Can I do that?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一般来说,是的,这是可以完成的,并且使用不同的 .NET ajax 框架来完成并不难。
很难提出“更好的选择”,因为这取决于您构建应用程序的方式及其不同的要求。
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.
将树视图包装在 UpdatePanel 中,并在代码隐藏中添加以下代码。 (假设您的右侧面板名为“PanelOnTheRight”,并且您有一个带有属性“IdToEdit”的用户控件“MyEditControl”)。
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').
您可以使用Page.LoadControl方法来加载用户控件。但我不确定它是否适用于 Ajax
You can use Page.LoadControl method to load user controls. But I am not sure whether it works with Ajax