2013-04-24 147 views
0

我需要訪問在母版頁中添加的tr控件,並使用子頁面顯示make。從子頁面訪問母版頁面的TR頁面

以下是代碼:

//MasterPage 
<tr runat="server" id="tr_Head" visible="false"> 
    //other controls 
</tr> 

在我childpage在頁面加載():

//ChildPage 
Control cnt = (Control)this.Master.Page.FindControl("tr_Head"); 
cnt.Visible = true; 

cnt我得到一個空引用異常。我如何使tr_Head從我的子頁面可見?

回答

0

我解決了它自己,

應該像

//ChildPage 
Control cnt = (Control)Master.FindControl("tr_Head"); 
cnt.Visible = true; 
訪問
相關問題