0

我正在处理一个 asp .net 项目,我有一个主 ascx 控件,它被两个 RadSpliters 划分。在加载 main.ascx 时,应用程序正在加载另外两个控件,control1.ascx 和 control2.ascx。在 control1 我有一个树视图,在树视图的选定节点上我想重新加载 control2.ascx。有没有办法做到这一点。下面我粘贴了我用来执行此操作但不起作用的代码。请问有什么帮助或建议吗?

  public partial class Control1: System.Web.UI.UserControl
{
        protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        BrowseProject b = new BrowseProject();
        b.load();
    }




public partial class MainControl : System.Web.UI.UserControl
    {
            public void load()
        {
                Control codeEditor = Page.LoadControl("Control2.ascx");
            PlaceHolder4.Controls.Clear();
            PlaceHolder4.ID = "PlaceHolder4";
            PlaceHolder4.Controls.Add(codeEditor);

        }
4

1 回答 1

0
public interface IReload{
    public void reload();
}

public partial class Control2: System.Web.UI.UserControl, IReload
{

}

public partial class Control1: System.Web.UI.UserControl
{
    IReload _r;

    public IReload setReload
    {
      set { _r = value; }
    }


    protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        BrowseProject b = new BrowseProject();
        b.load();
        if(_r != null){
            _r.reload();
        }
}

public partial class MainControl : System.Web.UI.UserControl
{
        public void load()
    {
        Control codeEditor = Page.LoadControl("Control2.ascx");
        PlaceHolder4.Controls.Clear();
        PlaceHolder4.ID = "PlaceHolder4";
        PlaceHolder4.Controls.Add(codeEditor);

        c.setReload(codeEditor);
    }
于 2012-07-20T09:50:17.343 回答