a class inherited from ArrayList, is saved to ViewState, why the type of the object read from ViewS

L

leal ting

a class inherited from ArrayList,
is saved to ViewState,
why the type of the object read from ViewSate is not the class,
but the parent, ArrayList
[my email address (e-mail address removed)]


the class inherited from ArrayList

public class Fields: ArrayList
{
public Fields()
{}
}


Save to ViewState
this.ViewSate["FieldList"] = colFields;

when reading, it raises an error,
Fields colFields = (Fields)this.ViewSate["FieldList"]


the right type
ArrayList colFields = (ArrayLiist) this.ViewState["FieldList"];

why? how to solve it? and how to read it directly?
 
B

Bryan Donaldson

I have the same issue, but in VB.Net. In my attempts to solve it, I modified
the class as follows, but that didn't change the behavior:

<Serializable()> public class Fields
inherits ArrayList
implements ISerializable

private sString as String
private nInt as Int

public sub New()
end sub

public sub New( byval info as Serializationinfo, byval c as
streamingcontext)
' get variables from info
end sub

sub getobjectdata(byval info as Serializationinfo, byval c as
streamingcontext) implements Iserializable
'save variables to Info
end sub
end class
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top