CompositeControl and ViewState

B

BjornColtof

I'm trying to create a CompositeControl derived class to implement a control
that will enable people to edit an account object. The properties of an
account like email, name, etc. should be edited with textboxes. A
CompositeControl-derived class should fit this scenario. The problem I'm
running into is that although I can set the initial entries in the textboxes,
I don't know how to retrieve them at runtime.

I have a property on the control like userName that does something like this:

public string UserName
{
get
{
return (string) ViewState["UserName"];
}

set
{
ViewState["UserName"] = value;
}
}

In the function CreateChildControls I create the check box an set its
initial value to the value of this property, which I set in the OnLoad of the
Page (if !IsPostback). My problem is that in the handler of the change button
(which isn't part of the control) I don';t know how to retrieve the new
UserName. Quering the property above will only result in the old value. How
can I put the right value of the UserName property into the ViewState?
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top