Controls.AddAt appears to be replacing controls

G

Guest

The problem is when I add a control using Controls.AddAt(index, control). On
the first page postback it appear to work fine but after the first postback
the last control in the naming container appears to be replaced with the
control that I'm adding in addition to adding the control at the given index.
After each additional postback a further control gets replaced until the
viewstate becomes corrupt and the page errors. If I add the control with
Controls.Add(control) I don't get this problem after multiple postbacks but
the control isn't added where I need it to be.

I'm adding the control from the Validate function from the IValidator
interface from an object that is added to the page's validators collection in
the page's onload event.
 
W

Walter Wang [MSFT]

Hi,

Posting some code or creating a repro project will make it much easier to
work with such issue.

Without code, my guess is that you're not assigning ID to the control
you're adding to the Controls collection. Without specifically designating
the ID of the control, the Control's ID will be generated using the index.
Since you're adding controls using some fixed position, it may confuse the
runtime that's loading/saving viewstates. If I've misunderstood anything,
please feel free to post here.



Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top