0
我正在構建基於指定狀態在頁面上呈現HTML的複合控件。複合控件中的面板忽略可見性
如果我設置了控件,並將其添加到ControlCollection
進行合成,並在設置爲false
時設置控件的可見性,它似乎工作正常,面板隱藏,直到頁面上的回傳導致要顯示的面板。
但是,當我在Render
方法中包裝RenderBeginTag(writer)
和RenderEndTag(writer)
時,它似乎忽略了初始化過程中的「visible = false
」語句?
// initialization
this._contentPanel = new Panel();
this._contentPanel.ID = "ContentPanel";
this._contentPanel.Visible = false;
this.Controls.Add(this._contentPanel);
// CreateChildControls
this.InitContentPanel(); // adds the content panel to control collection
// render
this._contentPanel.RenderBeginTag(writer);
writer.WriteLine("<div>Some copy here</div>");
this._contentPanel.RenderEndTag(writer);
這基本上仍然顯示面板,無論初始化過程中的可見性檢查。我已經測試過各種不同的場景,出於某種原因,這只是忽略了狀態。有任何想法嗎?
謝謝,
埃裏克