473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Serialize CommandEventHandler to ViewState?

DC
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
Jun 27 '08 #1
2 1079
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
Jun 27 '08 #2
DC
On 15 Apr., 03:05, bruce barker <nos...@nospam.comwrote:
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
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
1
by: Craig Buchanan | last post by:
I am trying to serialize a class called Order to the ViewState. Order has one property called LineItems, which is an ArrayList. The ArrayList holds instances of a class named LineItem. Bother...
7
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get...
7
by: Ben Amada | last post by:
I've created a class that I need to store in ViewState. However when I try to store it in ViewState, I get the following error: "The type 'solution.pe2' must be marked as Serializable or have a...
4
by: Islamegy® | last post by:
In my EntityCollection inherted from CollectionBase I marked it and Implement ISerializable Interface.. here is the code.. GetObjectDate( .....)...
6
by: Joe | last post by:
Hello All, I want to serialize a hashtable to a database table to persist its values between postbacks. The client requires that I not use ViewState, hence the database. The samples in MSDN...
1
by: David Lozzi | last post by:
Howdy, A little background, using asp.net 2.0, i'm using a wizard object to create a email interface for a user to email out their clientele, about 200 or so, depending on the selection. The...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.