ViewState of the Composite Control composed of custom control

W

whoisnidhee

I have a web server control that renders itself as a Rectangle with
some other properties like ID etc. I have another Composite Control
that contains an ArrayList. This ArrayList contains a collection of
Rectangles with different IDs. The Composite Control implements the
IPostBackEventHandler interface and contains an HTML Button control
that generates a Postback.
The problem is that I am unable to save the ViewState of the Composite
Control. The error I get is "The type 'Controls.Rectangle' must be
marked as Serializable or have a TypeConverter other than
ReferenceConverter to be put in viewstate. "
Marking the control as Serializable also resulted in the same error.
 
X

XicoLoKo

In that case I would make these changes:

- The ArrayList should contain Rectangle definitions (not a control by a class with each rectangle information) no Rectangle controls

- In the CreateChildControls override of your Composite control create one Rectangle control for each rectangle information contained in the ArrayList. Add them to the composite controls collection.

- xicokoko -
 
N

Nidhee

Thanx for the help.
I was able to do it by implementing the ISerializable interface in teh
Rectangle class. Also, my ArrayList still contains the Rectangle
control and is able to maintain its viewstate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top