Ask a Question related to ASP.NET General, Design and Development.
-
PJ #1
Re: Deserializing custom ArrayList type from ViewState... help..
> // this doesn't work
try:> EmployeeList ml (EmployeeList)ViewState["test"];
ViewState["test"] = ml;
make sure the classes that are stored in the arraylist are attributed w/
[Serializable] as well.
"Ramzey" <jeremy_deats@hotmail.com> wrote in message
news:d393d1b1.0306241208.38d78c85@posting.google.c om...> I have a custom class that uses ArrayList as its base type. I've
> tagged on the [Serializable] attribute to the class definition and I
> can add the class to ViewState or Session on my ASP.NET page.
>
> // this works fine
> EmployeeList myemp = new EmployeeList();
> myemp.Add(emp1);
> myemp.Add(emp2);
> ...
>
> ViewState["test"] = myemp;
>
>
> The problem comes when trying to cast my custom collection out of
> ViewState. The failure occurs when I try to cast it out, however if I
> try to cast back to ArrayList that works fine.
>
> e.g.
>
> // this works
> ArrayList ml = (ArrayList)ViewState["test"];
>
> // this doesn't work
> EmployeeList ml (EmployeeList)ViewState["test"];
>
> What do I need to add inside my custom collection object to make it so
> that ViewState can cast back to it when deserialization occurs?
PJ Guest
-
viewstate and custom control
I have custom control with dropdownlist. I am using this custom control in a repeater. After the post-back the control properties that i stored in... -
Custom control viewstate (?) issue!
I've been struggling for a day and yet haven't found a solution to such a problem: I have, let's say, an apsx page, which contains a UserControl,... -
Losing viewstate in custom control
I have a custom control I derived from the datagrid control and set a couple of values in viewstate("foo") = "bar" but on postback they are... -
Visual Studio.NET 2003 generates type object[] for ArrayList method return
I've noticed what appears to be a bug in the Visual Studio.NET (1.0 and 2003 versions). If I declare a web method like so: public ArrayList... -
Missing Viewstate in Custom Control
Easy one for gurus:::: Could someone tell me why this custom control bombs during postback? To duplicate: compile this control, put it in your... -
Ramzey #2
Re: Deserializing custom ArrayList type from ViewState... help..
All classes down the chain are tagged [Serializable]. If this were a
problem I wouldn't be able to cast back to an ArrayList type either,
but since I can it seems I have something missing from my EmployeeList
class. It seems during the deserialization process the deserializer
wants to cast it back to an ArrayList type. I assume deserializer
method call from ViewState is getting a response back from my custom
object that it should be cast to an ArrayList type.. The Microsoft
documention makes sense, but it doesn't address this.
Ramzey Guest



Reply With Quote

