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
    {
    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?
     
    BjornColtof, Nov 1, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mantorok

    Adding validators to CompositeControl

    Mantorok, Jun 15, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    656
    Mantorok
    Jun 15, 2006
  2. Mantorok
    Replies:
    2
    Views:
    1,390
    Mantorok
    Jun 22, 2006
  3. CMM

    CompositeControl and Toolbox

    CMM, Apr 18, 2006, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    142
  4. CMM

    CompositeControl and Toolbox

    CMM, Apr 18, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    117
  5. Replies:
    0
    Views:
    207
Loading...

Share This Page