Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 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

Reply
Thread Tools

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

 
 
leal ting
Guest
Posts: n/a
 
      12-29-2003
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 http://www.velocityreviews.com/forums/(E-Mail 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?




 
Reply With Quote
 
 
 
 
Bryan Donaldson
Guest
Posts: n/a
 
      02-10-2004
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

"leal ting" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 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?
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Class.inherited' v. 'inherited' syntax inside Class 7stud -- Ruby 11 11-09-2007 06:45 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Saved Mail Gone and Sent Mail Not Being Saved Gregg Firefox 6 03-06-2006 02:13 AM
ViewSate is not saved Bugge ASP .Net Building Controls 1 02-14-2004 01:31 AM
Viewsate errors Matt ASP .Net 1 10-21-2003 06:03 PM



Advertisments