Serialize a class to viewstate?

Discussion in 'ASP .Net Web Controls' started by Manit Chanthavong, Jan 7, 2004.

  1. I've read every and have not been able to make serialize a custom class int
    a view state. Does anyone have a good example of how this is done? here is
    what I have so far: The code seems to throw an error at:
    format.Serialize(writer, Items);

    [Serializable]
    public class RdButtonList: Control, IPostBackDataHandler
    {

    protected override object SaveViewState(){

    ArrayList Items = new ArrayList();

    LosFormatter format = new LosFormatter();
    StringWriter writer = new StringWriter();
    format.Serialize(writer, Items);
    ViewState["Items"] = writer.ToString();

    return base.SaveViewState();
    }
    }

    Here is the error I'm getting:

    must be marked as Serializable or have a TypeConverter other than
    ReferenceConverter to be put in viewstate.

    Please help! Thanks,

    Manit
    Manit Chanthavong, Jan 7, 2004
    #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. Craig Buchanan

    serialize class to the viewstate

    Craig Buchanan, Jan 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,162
  2. Gordz
    Replies:
    3
    Views:
    3,923
    John Oakes
    Jun 7, 2004
  3. Ben Amada

    Can viewstate serialize this class?

    Ben Amada, Oct 16, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    13,110
    john_teague
    Oct 30, 2005
  4. DC
    Replies:
    2
    Views:
    379
  5. Alex

    Serialize Style to save ViewState

    Alex, Mar 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    320
    Teemu Keiski
    Mar 25, 2005
Loading...

Share This Page