I have been having a state management issue with a composite custom control that I created. This control is made invisible as a result of a post-back event. It remains invisible until a button on the form is clicked. The control in question is a list. When an item in the list is clicked, the control is hidden and a data entry form is displayed where the user can update information for the item which was clicked. In the data entry form is another list, which provides the same functionality. An item can be clicked, and data can be updated for that item.
During all of this the original list remains invisible. However, I need it's state to be maintained so that when the update is done, or canceled, I can once again display the list, and not need to rebind the data. Herein is where my problems began.
Apparently, CreateChildControls() is not called for a control when it is invisible, and a post-back event occurs. However, OnInit() and OnLoad() are called. So, the solution to my dilemma was easy, though it leaves very uneasy. I override the OnLoad event for my list control. It looks like the following:
protected override void OnLoad(EventArgs e)
{
EnsureChildControls();
base.OnLoad (e);
}
Tuesday, October 04, 2005
.NET State Management
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment