Composite & issues with Viewstate/Enabled property

A

Andrew Backer

I have pretty simple composite control consisting of a textbox and
image control. On the composite control I have defined my own
'Enabled' property which simply calls into the sub-controls and sets
their Enabled property. I am inheriting from Web.UI.Control, not
WebControls.Control.

The problem is that, after the first time I set it, I can not 'un-set'
it. It appears that I can call the .Enabled method and it does
everything right, but at the very last moment something else overrides
me. The call statck looks something like this :

Page Event Handler (click)
... this.compControl.Enabled = true; // was false
... CompControl::CreateChildControls() - _text.Enabled is 'true'
... CompControl::OnPreRender() - _text.Enabled is 'true'

Where do I need to put this call in order to get this to stick? I have
gotten the image to work by turning off viewstate for it, but I don't
understand whats going on! My trace looks like this :

aspx.page End ProcessPostData Second Try
aspx.page Begin Raise ChangedEvents
..Enabling Controls-------------
aspx.page End Raise ChangedEvents
aspx.page Begin Raise PostBackEvent
aspx.page End Raise PostBackEvent
aspx.page Begin PreRender
..Enabling Controls-------------
...DateTextbox::CreateChildControls()
....._textbox.enabled : True
....._picker.enabled : True
...DateTextBox::OnPreRender()
....._textbox.Enabled = False
....._picker.Enabled = True
.........DatePicker::OnPreRender() : True

Thanks for any help,
Andrew Backer
 
A

Andrew Backer

I put a call to EnsureChildControls() in my constructor and it works.
This feels like a hack, since CreateChildControls() should get called
for me, right? If there is a "proper" way to do this I would love to
know ;)

The trace output from CCC disappears, which means it's getting called
WAY early, before trace is available I assume.

- Andrew Backer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top