查找在同一页面另一个用户控制用户控制的控制 [英] Find user-control's control from another user-control in same page

查看:138
本文介绍了查找在同一页面另一个用户控制用户控制的控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个用户控件树状里面。


现在,我已经在 aspx页面与一些不同的编号让我们说 usercontrolA把它放在两次 usercontrolB


两者都在一个页面由一个加载。

现在 pre-渲染 usercontrolA 事件我想获得的对象 usercontrolB 的树状控制。

我怎样才能实现呢?

I have created an usercontrol that has treeview inside.

Now I have placed it in an aspx page twice with some different Id let us say usercontrolA and usercontrolB.

Both of them are loaded in to page one by one.
Now in pre-render event of usercontrolA I want to get the object of treeview control of usercontrolB.

How can I achieve it?

推荐答案

您需要具备的实例的usercontrolB 访问同时为用户控件树视图控制。因此,尝试的 preserving 的一些合适的存储实例访问它在 pre-渲染事件。

You need to have the instance of usercontrolB to access the treeview control for both the user controls. So try preserving the instance in some appropriate storage to access it in the pre-render event.


  1. 介绍一个属性来保存UC键入用户控制在

public MyUserControl MainUserControl { get; set; }


  • 在父ASPX设置财产 usercontrolB

    usercontrolA.MainUserControl = usercontrolB;
    usercontrolB.MainUserControl = usercontrolB;
    


  • 现在,你可以使用 MainUserControl 属性来访问你的 TreeView控件

    MainUserControl.treeView1 ...
    


  • 这篇关于查找在同一页面另一个用户控制用户控制的控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆