0
我有一個aspx頁面,其中有Ajax UpdatePanel,它有一個AJAX Tabcontainer,它有5個選項卡。在第一個選項卡中,我有一個ProductD的DropDownList。在第二個選項卡中,我使用了一個UserControl,它的參數需要根據productID來反映。我想訪問我沒有得到的用戶控件中的DropDownList ProductID。我的部分代碼是在子級用戶控件中訪問父頁面控件
DropDownList IDList = (DropDownList)(this.Parent.FindControl("ProductID");
這不工作,我得到NULL。我也試過了
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的,這我沒有得到。對於修復,我定義了一個返回此列表值的Public函數。但它的修復不是解決方案。
我也不讓TabContainer的控制就說明它NULL,我也試過這樣的更新面板整體TabContainer的是UpdatePanel中,即使不工作 –
沒有你試過UpdatePanel1.FindControl(「TabContainer的」) –
是的,我做了,甚至UpdatePanel控件不在用戶控件 –