473,320 Members | 2,145 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,320 software developers and data experts.

Add a UserControl to an ArrayList

Hi, does anyone have an Idea if it's possible to add a UserControl
(containing serveral other controls like textboxes and/or
dropdownlists) to an ArrayList?

If I just put [Serializable] at the top of the class of the
UserControl, it does not make a difference, I keep getting the error:
The type 'ASP.UCXXXXXXX_ascx' must be marked as Serializable or have a
TypeConverter other than ReferenceConverter to be put in viewstate.

Also adding the interface ISerializable doesn't work. Maybe it's not
possible at all.

Anyone?

Thanks

Apr 7 '06 #1
3 1170
You can't do that. You can't just serialize an entire user control ito
viewstate.

Normally, people simply store the path to the user control in the viewstate
and reload them on postback

foreach(string controlPath in (ArrayList)ViewState["ControlsToReload"])
{
SomePlaceHolder.Controls.Add(Page.LoadControl(cont rolPath));
}

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<s.*******@symax.nl> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Hi, does anyone have an Idea if it's possible to add a UserControl
(containing serveral other controls like textboxes and/or
dropdownlists) to an ArrayList?

If I just put [Serializable] at the top of the class of the
UserControl, it does not make a difference, I keep getting the error:
The type 'ASP.UCXXXXXXX_ascx' must be marked as Serializable or have a
TypeConverter other than ReferenceConverter to be put in viewstate.

Also adding the interface ISerializable doesn't work. Maybe it's not
possible at all.

Anyone?

Thanks

Apr 7 '06 #2
Can you serialise just the bits you need to recreate the usercontrol?

Apr 7 '06 #3
Thanks Karl, I was afraid this would be the answer. To bad.

@Jason, I use a kind of construction Karl was refering to. What I do
is, I build an ArraList, in this list I add the controls ClientID. On
postback I recreate the control based on a foreach of all elements in
the ArrayList. This works fine. But yesterday I wanted to try to
changes records I use the UserControls with. That part I didn't figure
out yet, but I'm close. If you're intrested I could send you my code.
It's kind of difficult because I use nested controls until three levels
deep. Just send me you emailadress

Thansk for replying

Apr 8 '06 #4

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

Similar topics

0
by: Anon | last post by:
I am programmatically populating a asp.net table control with my usercontrol (PictureBox.ascx) which is basically an assortment of an imagebutton, Label and a Linkbutton. Now while debugging the...
6
by: steve bull | last post by:
I created a usercontrol class, RGBColorSpace, which is derived from an abstract class, ColorSpace, but when I try to click on the design panel for the control I get an error message "Unable to...
0
by: labelle | last post by:
I have two divs on an aspx, and each DIV holds a repeater which holds a UserControl. On the left hand side, I have a "feature list" with an "add to cart" button, and on the right hand side, a...
0
by: Phl | last post by:
Hi, I am trying to create an webform which loads usercontrols dyanamically. I know exactly what to load for some of these controls but for some, I dont want to load it until the user has press a...
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
9
by: Dominique | last post by:
I'm trying to create a C# composite control and have inherited from UserControl. This new control contains 9 buttons with images on them ( no text ). Firstly, what is the best way to expose...
5
by: Tarun Mistry | last post by:
Hi all, is it possible to update a usercontrol before it is rendered? In my scenario I have a Page with a usercontrol on it. When a button is clicked on the Page, I want to update the...
0
by: crespo | last post by:
hi,everyone. I have a question about using listbox in a customized user control.I use a listbox directly in a asp.net page and it works very well,but when I use the same code in a user...
0
by: Florian Paulus | last post by:
Hi group, I am kind of lost here. I have created a Usercontrol holding 2 grouped Radiobuttons. In one particular Wizardstep (the last one) they are dynamically (by code) added to the step :...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.