C# 访问子用户控件中的父页控件

C# 访问子用户控件中的父页控件,c#,asp.net,findcontrol,C#,Asp.net,Findcontrol,我有一个aspx页面,其中有一个Ajax UpdatePanel,它有一个Ajax Tabcontainer,它有5个选项卡。在第一个选项卡中,我有一个ProductID的下拉列表。在第二个选项卡中,我使用了一个UserControl,它的参数需要根据productID反映出来。我想访问用户控件中未获取的DropDownList ProductID。我的部分代码是 DropDownList IDList = (DropDownList)(this.Parent.FindControl("Prod

我有一个aspx页面,其中有一个Ajax UpdatePanel,它有一个Ajax Tabcontainer,它有5个选项卡。在第一个选项卡中,我有一个ProductID的下拉列表。在第二个选项卡中,我使用了一个UserControl,它的参数需要根据productID反映出来。我想访问用户控件中未获取的DropDownList ProductID。我的部分代码是

DropDownList IDList = (DropDownList)(this.Parent.FindControl("ProductID");
这是不工作的,我得到零。我也试过

DropDownList IDList = (DropDownList)(this.Page.FindControl("ProductID");
请告诉我怎么做

正如所要求的,必要代码的一部分是

<asp:UpdatePanel ID="UpdatePanelTankFormula" runat="server">
    <ContentTemplate>
        <asp:tabcontainer id="TabContainerTankFormula" AutoPostBack="true" runat="server" OnClientActiveTabChanged="clientActiveTabChanged"   activetabindex="0" style="width:100%;">  

           <asp:TabPanel ID="InputDataTab" runat="server"  HeaderText="Data Input">
               <ContentTemplate> 
                   <asp:DropDownList id="TankNameCombo" DataTextField="TankName" runat="server" AutoPostBack="true" DataValueField="customertankid"   width="200px" onclick="javascript:SetHiddenField();">    </asp:DropDownList>
               </ContentTemplate> 
           </asp:TabPanel>

           <asp:TabPanel ID="LacticAcidAdditionTab" runat="server"  HeaderText="Lactic Acid Addition">
               <ContentTemplate> 
                   //My user control
                   <UC:TankNote runat="server" ID="LaticTankNotesUC" GetNoteType="LAC" MEQMode="False"></UC:TankNote> 
               </ContentTemplate> 
           </asp:TabPanel>

        </asp:tabcontainer>
    <ContentTemplate>
</asp:UpdatePanel>

//我的用户控件

现在,在这个用户控件背后的代码中,我想访问这个DropDownList,我没有得到它。为了解决这个问题,我定义了一个公共函数,返回这个列表的值。但这是一个修复方案,而不是解决方案。

您将在选项卡控件中使用类似的功能

 <cc1:TabContainer ID="TabContainer1" runat="server">
    <cc1:TabPanel ID="TabPanel1" runat="server">
        <ContentTemplate>
            <asp:DropDownList id="dropdownlist1" runat="Server"/>
        </ContentTemplate>
    </cc1:TabPanel>

我甚至没有得到TabContainer控件,它显示为空,我也尝试了这个更新面板,因为整个TabContainer都在UpdatePanel中,即使它不工作是的,即使UpdatePanel控件也不在用户控件中我已经用必要的代码更新了帖子。请检查。您应该获得更新面板。在哪种情况下,您试图找到更新面板和子控件?是的,我应该得到它,但我不知道为什么它不来。我有一个按钮,在我的用户控件上的点击事件,我需要下拉列表
TabContainer TabContainer1= (TabContainer)(this.Page.FindControl("TabContainer1");
if (TabContainer1!=null){
TabPanel TabPanel1= (TabPanel)(this.TabContainer1.FindControl("TabPanel1");
if(TabPanel1 !=null){
DropDownList dropdownlist1= (DropDownList)(this.TabPanel1.FindControl("dropdownlist1");

}}