Re: IStateManager in a class object



Thanks for the reply....but you lost me there. If I'm using this in a page
I understand about overriding the pages LoadViewState, SaveViewState...and
calling the helper class LoadViewState, etc... The paradox I'm lost on is
how the instance of the helper is saved and reinstantiated such that the
value in it's statebag persist. The page needs to instantiate the helper
somewhere. And if the helper has a constructor which instantiates the
statebag, the statebag (and thus the viewstate) is going to be empty.




"Brock Allen" <ballen@xxxxxxxxxxxxxxxxx> wrote in message
news:b8743b1131b5c8c7933231a98e4c@xxxxxxxxxxxxxxxxxxxxxxx
This approach is typically done when a control (or the page) needs to use
a helper object to track the viewstate. So the usage model is for the
control
to instantiate an instance of the helper object and then override all of
the IStateManager APIs and call into the helper object for each one (so
override
LoadViewState and the call into the helper's LoadViewState, etc...). This
is how the helper object gets 'hooked into' the page model. I hope that just
made sense :)

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I am creating a class (not a control) which implements IStateManager.
> I've created the class and all of the implementations (LoadView,
> SaveViewState, etc...). My Question is: How do I instantiate this
> class in a page and then re-instantiate it on post back such that I
> don't lose it's viewstate? If the page always uses x = new myclass to
> instantiate, the myclass constructor is always going to reinitialize
> its statebag.
>



.



Relevant Pages

  • Re: IStateManager in a class object
    ... page's control collection. ... so you'll create the helper and it will be empty until ... LoadViewState ... |> needs to instantiate the helper somewhere. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IStateManager in a class object
    ... That's why it's important to forward the overrides to the helper. ... So, yes, ViewState won't be loaded until the Page base class calls the LoadViewState virtual. ... The page needs to instantiate the helper somewhere. ... And if the helper has a constructor which instantiates the statebag, the statebag (and thus the viewstate) is going to be empty. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IStateManager in a class object
    ... so you'll create the helper and it will be empty until LoadViewState is called. ... So, yes, ViewState won't be loaded until the Page base class calls the LoadViewState virtual. ... The page needs to instantiate the helper somewhere. ... So the usage model is for the control to instantiate an instance of the helper object and then override all of the IStateManager APIs and call into the helper object for each one (so override ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Threads in remoting
    ... > tried using your singleton to instantiate a new Helper class obejct for ... > could try a static method on the singleton like this ... > static HelperObj GetHelpObject() ...
    (microsoft.public.dotnet.languages.csharp)

Loading