2012-02-13 29 views
-2

我有一個帶有Accordion控件和按鈕(該頁面基於母版頁)的aspx頁面(Default.aspx)。 裏面一個這個手風琴的窗格中我有一個用戶控件,這樣的事情:來自userControl的FindControls在內容aspx中的Accordion頁面

<Content> 

<ucDetails:Details ID="userControlDetails" runat="server" /> 

</Content> 

現在我需要在aspx頁面我的用戶裏面的按鈕的Enabled屬性的訪問。

到現在爲止我已經試過:

Button btnSend1 = (Button) this.NamingContainer.FindControl("btnSendRequest"); 
Button btnSend2 = (Button) Page.Parent.Parent.FindControl("btnSendRequest"); 
Button btnSend3 = (Button) Page.Parent.FindControl("btnSendRequest"); 

第一個返回NULL 和其他人返回異常(「對象未設置實例的......」)。

我在哪裏錯了?

在此先感謝。

路易吉 :

回答

0
Button btnSend1 = new Button(); 
    btnSend1 = (Button)userControlDetails.FindControl("btnSend1"); 
    bool enabled = btnSend1.Enabled; 

這是你要什麼?

+0

我試過這個: Button btnSend1 = new Button(); btnSend1 =(Button)Parent.FindControl(「btnSend1」); bool enabled = btnSend1.Enabled; 但它給了null。 userControl位於Default.aspx頁面中的Accordion窗格內。 Luigi – Ciupaz 2012-02-14 08:46:37

相關問題