Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > viewstate and the IStateManager interface

Reply
Thread Tools

viewstate and the IStateManager interface

 
 
Rowland Shaw
Guest
Posts: n/a
 
      01-25-2005
All the documentation I've found suggects that all you need to support on
your object to stick it in the ViewState on a control is the IStateManager
interface.

However, with the IStateManager interface implemented (in my example on
ComplexObject), I get the infamous error:
[HttpException (0x80004005): The type 'MyCompany.MyProject.ComplexObject'
must be marked as Serializable or have a TypeConverter other than
ReferenceConverter to be put in viewstate.]

There's been a lot of head scratching, and a lot of flicking through pages
245 to 255 of MS Press' "Developing Asp.Net Server Controls and Components";
but I'm still no wiser -- am I missing something blindingly obvious or is
there really an amount of black magic required? (I suspect the former)
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      01-26-2005
Hi,

IStateManager means that object itself implements a interface similar to
controls which have state management capability, means objects themselves
save something (their current state) to view state (IStateMamager declares
the inetrface for these saving/loading/tracking methods), but object
instances itself are not put into the view state.

E.g state and instances are kept separately (instances are recreated on
postback and view state is then loaded to them to restore the state).
IStateManager is meant to obejcts which aren't controls but work in the same
context for example control styles, ListItems and so on.

If you put object instances to ViewState, their implementation of
IStateManager has nothing to do with this process but as error message
indicates, in that case objects must have Serializable attribute applied to
the class for automatic serialization and you can further customize this
process by implementing ISerializable interface.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU


"Rowland Shaw" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> All the documentation I've found suggects that all you need to support on
> your object to stick it in the ViewState on a control is the IStateManager
> interface.
>
> However, with the IStateManager interface implemented (in my example on
> ComplexObject), I get the infamous error:
> [HttpException (0x80004005): The type 'MyCompany.MyProject.ComplexObject'
> must be marked as Serializable or have a TypeConverter other than
> ReferenceConverter to be put in viewstate.]
>
> There's been a lot of head scratching, and a lot of flicking through pages
> 245 to 255 of MS Press' "Developing Asp.Net Server Controls and
> Components";
> but I'm still no wiser -- am I missing something blindingly obvious or is
> there really an amount of black magic required? (I suspect the former)



 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      01-26-2005
And to add, yes option to having Serializable attribute is developing a
TypeConverter for your object, it is the most efficient solution from
viewstate standpoint. The key point in understanding what I said is
explained on pages 245-246

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU


"Rowland Shaw" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> All the documentation I've found suggects that all you need to support on
> your object to stick it in the ViewState on a control is the IStateManager
> interface.
>
> However, with the IStateManager interface implemented (in my example on
> ComplexObject), I get the infamous error:
> [HttpException (0x80004005): The type 'MyCompany.MyProject.ComplexObject'
> must be marked as Serializable or have a TypeConverter other than
> ReferenceConverter to be put in viewstate.]
>
> There's been a lot of head scratching, and a lot of flicking through pages
> 245 to 255 of MS Press' "Developing Asp.Net Server Controls and
> Components";
> but I'm still no wiser -- am I missing something blindingly obvious or is
> there really an amount of black magic required? (I suspect the former)



 
Reply With Quote
 
Rowland Shaw
Guest
Posts: n/a
 
      01-27-2005
Thanks for taking the time to reply -- I think I'm a bit cleaer now.

If/when I get a chance, I'll have to sit down and write an article on how to
do this and explain it in terms I'd understand for the next time I (or anyone
else) comes across this...


"Teemu Keiski" wrote:

> And to add, yes option to having Serializable attribute is developing a
> TypeConverter for your object, it is the most efficient solution from
> viewstate standpoint. The key point in understanding what I said is
> explained on pages 245-246
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
>
>
> "Rowland Shaw" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > All the documentation I've found suggects that all you need to support on
> > your object to stick it in the ViewState on a control is the IStateManager
> > interface.
> >
> > However, with the IStateManager interface implemented (in my example on
> > ComplexObject), I get the infamous error:
> > [HttpException (0x80004005): The type 'MyCompany.MyProject.ComplexObject'
> > must be marked as Serializable or have a TypeConverter other than
> > ReferenceConverter to be put in viewstate.]
> >
> > There's been a lot of head scratching, and a lot of flicking through pages
> > 245 to 255 of MS Press' "Developing Asp.Net Server Controls and
> > Components";
> > but I'm still no wiser -- am I missing something blindingly obvious or is
> > there really an amount of black magic required? (I suspect the former)

>
>
>

 
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
Problems with ViewState: "function 'ViewState.get_Item' evaluated and returned null" Steph ASP .Net 2 05-11-2011 02:35 PM
IstateManager Problem dionysus_sh ASP .Net 0 10-25-2007 12:59 PM
IStateManager in a class object Brad ASP .Net 6 10-10-2005 10:05 AM
IStateManager interface at design-time? Jiho Han ASP .Net Building Controls 1 01-19-2004 07:54 PM
Corrupted ViewState (Yes, another issue concerning viewstate) Ben Rush ASP .Net 2 12-05-2003 04:17 PM



Advertisments