2010-07-23 14 views
0

本頁佈局的方式是,所有的數據都在Page_Init加載。那麼,我有一個自定義控件,但有這個問題。調用EnsureChildControls()後,所有控件仍然爲空?

我有它的網頁上,像這樣:

<cc:SomeControl... /> 

然後我設置使​​用

MyControl.Value="blah"; 

簡單的東西在Page_Init值..

Value是訪問和有類似的東西:

public string Value{ 
    get... 
    set{ 
    EnsureChildControls(); 
    MyHiddenField.Value=value; 
    } 
} 

這是我的問題。它說MyHiddenField爲空。 Page_Init爲時過早嗎?還是有一些其他功能需要調用?

回答

0

這種情況的修復程序使用命名空間改變爲CustomControl參照使用src用一個文件名

改變該:

<%@ Register Assembly="MyProduct" Namespace="MyProduct.CustomControls" TagPrefix="cc" %> 

這樣:

<%@ Register src="/CustomControls/MyControl.ascx" tagname="MyControl" tagprefix="uc2" %> 
相關問題