我的问题具有一定的相关的主题:一个按钮被点击时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