我的問題具有一定的相關的主題:一個按鈕被點擊時How to avoid Initialization of web user control inside aspx?ASP.NET用戶控件:檢查,如果用戶控件是可見
的用戶控件只應是可見的。 所以我的用戶設置是這樣的:
<example:usercontrol ID="idControl" runat="server" Visible="false" />
<asp:Button ID="showMyControl" runat="server" OnClick="ShowMyControl"/
而且用戶控件本身檢查他是否可見:
protected void Page_Load(object sender, EventArgs e) {
// only execute if the user control is visible
if (this.Visible) {
...
}
}
當我按一下按鈕我的Visible屬性的用戶控件的設置爲true,但當發生回發時,usercontrol的Page_Load中的Visible-property仍然設置爲false。
我的用戶控件可能先被加載,然後設置Visible屬性? 有沒有簡單的方法來解決這個問題?
提前致謝!
這不是解決方案,但我不知道這種方法,所以畢竟我學到了新東西:) – thomasvdb 2010-07-19 15:03:13