Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Serialize CommandEventHandler to ViewState?

Reply
Thread Tools

Serialize CommandEventHandler to ViewState?

 
 
DC
Guest
Posts: n/a
 
      04-14-2008
Hi,

I would like to reuse a webcontrol in several places and when a
certain action is being executed in the webcontrol, a defineable
method should run. That method of course is defined in an event in the
webcontrol:

public event CommandEventHandler MyCallBack;

Now in the hosting control I can do stuff like

myCallBack += this.MyCallbackHandler;

and that will work for that one request, but I have to specify
MyCallbackHandler at every roundtrip. Is it possible to store this
information somehow? I played around with ViewState, but I found out
that a CommandEventHandler cannot be serialized. Am I missing a design
rule?

TIA,
DC
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      04-15-2008
object addresses can not be serialized. you could copy the browsers and
have a string method to store the callback. then on callback use
refection to call the routine.

not sure why you do not want to hookup the callback every postback? some
code has too as they are new class instances.

-- bruce (sqlwork.com)

DC wrote:
> Hi,
>
> I would like to reuse a webcontrol in several places and when a
> certain action is being executed in the webcontrol, a defineable
> method should run. That method of course is defined in an event in the
> webcontrol:
>
> public event CommandEventHandler MyCallBack;
>
> Now in the hosting control I can do stuff like
>
> myCallBack += this.MyCallbackHandler;
>
> and that will work for that one request, but I have to specify
> MyCallbackHandler at every roundtrip. Is it possible to store this
> information somehow? I played around with ViewState, but I found out
> that a CommandEventHandler cannot be serialized. Am I missing a design
> rule?
>
> TIA,
> DC

 
Reply With Quote
 
 
 
 
DC
Guest
Posts: n/a
 
      04-15-2008
On 15 Apr., 03:05, bruce barker <(E-Mail Removed)> wrote:
> object addresses can not be serialized. you could copy the browsers and
> have a string method to store the callback. then on callback use
> refection to call the routine.
>
> not sure why you do not want to hookup the callback every postback? some
> code has too as they are new class instances.
>
> -- bruce (sqlwork.com)
>
>
>
> DC wrote:
> > Hi,

>
> > I would like to reuse a webcontrol in several places and when a
> > certain action is being executed in the webcontrol, a defineable
> > method should run. That method of course is defined in an event in the
> > webcontrol:

>
> > public event CommandEventHandler MyCallBack;

>
> > Now in the hosting control I can do stuff like

>
> > myCallBack += this.MyCallbackHandler;

>
> > and that will work for that one request, but I have to specify
> > MyCallbackHandler at every roundtrip. Is it possible to store this
> > information somehow? I played around with ViewState, but I found out
> > that a CommandEventHandler cannot be serialized. Am I missing a design
> > rule?

>
> > TIA,
> > DC- Zitierten Text ausblenden -

>
> - Zitierten Text anzeigen -


Thanks, Bruce. I thought it was more convenient to set the callback
only once but you are actually right, it is not that much effort to
wire it up on every postback.

Regards
DC
 
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
Problem with AddHandler (New CommandEventHandler) under framework 2.0 Fabrice ASP .Net 7 06-27-2009 12:26 PM
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'. Mike Larkin ASP .Net 1 05-23-2005 12:33 PM
How to Add CommandEventHandler Dynamically AND CONDITIONALLY! haile ASP .Net Web Controls 1 11-24-2004 01:59 PM
serialize to SQL Server Blob instead of XML serialize Gordz ASP .Net 3 06-07-2004 07:46 PM
How to Serialize System.Drawing.Pen Sergio Dinis ASP .Net 1 10-03-2003 03:40 AM



Advertisments