CompositeControl and ViewState

Discussion in 'ASP .Net Building Controls' started by BjornColtof, Nov 1, 2005.

  1. BjornColtof

    BjornColtof Guest

    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
    return (string) ViewState["UserName"];

    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?
    BjornColtof, Nov 1, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.