Serialize a class to viewstate?

  • Thread starter Manit Chanthavong
  • Start date
M

Manit Chanthavong

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
 

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,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top