Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
I have one usercontrol, one webpage (aspx) in aspx page i have two panels.
i want to find 2panels from aspx page to usercontrolpage.

PLease send me anyone.

Thanks
Posted

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;
            }
 
Share this answer
 
hi,

Create property for panel and then expose those. After that you will be able to access from UC.

for ex.
C#
public string MyPanel
    {
      get { return panelName; }
    }


Or you can use below technique.

C#
protected void UCMethod()
{    
   Page myParent = this.ParentPageName;    
   Panel panel = myParent.PanelId; //Here you can access any property of parent page
}
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900