我正在开发一个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);
}
答案 0 :(得分: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);
}