The control I'm making is basically an editable datagrid. I'm serializing
multiple instances of it to Session (Session != Cache, right?) so that
I
can
re-add them to the page after a postback.
What other method would you suggest?
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
why are you adding your control to cache?
controls don't work right when serialized./deserialized from cache (at
least
in 1.0 version) not sure if they addressed that for 1.1
--
Regards,
Alvin Bruney
[ASP.NET MVP
http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here...
http://tinyurl.com/27cok
INamingContainer is irrelevant - same error whether or not it's
declared.
This is a problem with the control itself and its relationship to
the
containing page, not the IDs of child controls.
The problem was actually that when the controls are created, they're
always
created with an ID of _ctl0. So, when I pull a reference to the control
out
of session state and add it back to the page, I end up adding multiple
controls with the same ID. This confiuses ASP.NET, and so I end up with
an
error.
I didn't find a way to persuade ASP.NET to automatically create a
unique
ID,
so I'm now generating a Guid to use as a Session state key and control
ID,
and explicitly assigning my controls an ID in the Init phase of the
page
lifecycle.
I'm not sure that a Guid is the best/most elegant way to do it, but
it's
the
least amount of code required to generate something I know to be unique
(hence the note "solved by hackery")..
[This followup was posted to
microsoft.public.dotnet.framework.aspnet.webcontrols and a copy was
sent
to the cited author.]
I've a web page that adds a custom control every time a button is
clicked.
I'm keeping a reference to each added control in Session state so I
can
recreate existing controls every postback. However, the controls are
always
added with ID "_ctl0" rather than "_ctl1", "_ctl2" ..., so I get an
error:
"Multiple controls with the same ID '_ctl0' were found. FindControl
requires
that controls have unique IDs". What do I need to do to get this to
work?
Thanks,
Owen
Perhaps you are missing a INamingContainer implementation. Please let
me
know if this helps you