A page(a.aspx) load a userWebControl(b.ascx) userWebControl(b.ascx) create a new TextBox txtB and set txtb.ID="BBB",what is the name of txtB in webpage(a.aspx).I view a.aspx source code in IE only ID="BBB" no Name=something. so I CAN NOT locate the txtB control by using FindControl("BBB").a.aspx
TextBox b = FindControl("BBB");
//b=null
p.s. I can not input chinese, sorry about that.

解决方案 »

  1.   

    first
      userWebControl usrC = findcontrol("userWebControl1")
    next
      textbox b = usrC.findControl("BBB");
    try it 
      

  2.   

    thanks. but it doesn't work.////////////////////////////////////////
                ScheduleItemFields schItem = (ScheduleItemFields)LoadControl("ScheduleItemFields.ascx");
                schItem.ID = "AAA";
                m_panScheduleItem.Controls.Add(schItem); //m_panScheduleItem is a Panel
    ...            this.FindControl("AAA") //return null
                this.FindControl("m_panScheduleItem").FindControl("AAA")  //return null//this.FindControl("m_panScheduleItem")  dosen't return null but this.FindControl("m_panScheduleItem").FindControl("AAA") DOES
      

  3.   

    我创建了一个用户控件 ProductGroupDropDown ,里面有一个DropDownList1
    然后 在界面上拖放了一个panel,后台代码如下 ProductGroupDropDown pgd = (ProductGroupDropDown)LoadControl("~/Control/ProductGroupDropDown.ascx");
                pgd.ID = "aaa";
                Panel1.Controls.Add(pgd);
                Panel p1 = (Panel)Master.FindControl("ContentPlaceHolder1").FindControl("Panel1");
                if (p1 == null)
                {
                }
                else
                {
                    ProductGroupDropDown pd1 = (ProductGroupDropDown)p1.FindControl("aaa");
                    DropDownList dr = (DropDownList)p1.FindControl("DropDownList1");
                }
    我测试 是可以的,你看看
      

  4.   

    ContentPlaceHolder1 先找到这个ContentPlaceHolder,然后找 Panel
    ,然后 通过Panel 找用户控件,并且可以找到 用户控件的 dropdownlist
      

  5.   

    unfortunately, it still doesn't work. I just copy whole asxc code to aspx
    thank you.