更新时间:2023-12-06 12:11:58
System.Web.UI.WebControls.Panel myPanel = null;
Control ctl = this.Parent;
while (true)
{
myPanel = (System.Web.UI.WebControls.Panel)ctl.FindControl("myPanel");
if (myPanel == null)
{
if (ctl.Parent == null)
{
return;
}
ctl = ctl.Parent;
continue;
}
break;
}
为面板创建属性,然后公开这些属性.之后,您将可以从UC访问.
例如.
Create property for panel and then expose those. After that you will be able to access from UC.
for ex.
public string MyPanel
{
get { return panelName; }
}
或者您可以使用以下技术.
Or you can use below technique.
protected void UCMethod()
{
Page myParent = this.ParentPageName;
Panel panel = myParent.PanelId; //Here you can access any property of parent page
}