Steven,
The class defining my custom WebControl derives from CompositeControl, so the INamingContainer issue should be handled. This is all
under ASPNET2.
Removing the ViewState[] assignment does not solve the problem.
To reiterate, the question is this: under what circumstances will a control, when created as part of a composite control, initialize
itself from ViewState when it is recreated on postback?
The MSDN documentation is unclear to me on the subject. In some places it states that ASPNET server controls configure themselves
from ViewState when they are recreated on postback. In other places properties like Label.Text are explicitly stored and retrieved
to ViewState during control creation and re-creation.
I would appreciate some clarification.
- Mark
On Wed, 22 Feb 2006 03:02:30 GMT,
st*****@online.microsoft.com (Steven Cheng[MSFT]) wrote:
Hi Mark,
From the CreateChildControls method you posted, I think your current code
logic is correct except the below line:
===============
if( !UseStoredState )
{
lblCtl.Text = quesRow.text;
ViewState["questionId"] = quesRow.id.ToString();
}
==============
Try avoid access viewstate in CreateChildControls method since it is not
guranteed to be called after ViewState is loaded. In addition, since I do
not know how your control class is declaring, not sure whether you've
implemented the INamingContainer interface, this interface is necessary for
composite control which contains sub controls.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)