ClientID in Repeater gives the Control ID

V

Vincent Mouton

Hi,

I have never before encountered this problem. I'm trying to retreive the
(unique) ClientID from a TextBox inside an ItemTemplate of a Repeater.
The purpose is to add it to a Button in that same ItemTemplate for
validation purposes.

The ClientID returns the Control's ID, not the generated ID that will be
used in the output HTML.

My page implements the System.Web.UI.INamingContainer interface. My
Control that holds the repeater does also.

I don't get what I am doing wrong.

greetings,
Vincent
 
J

Jeffrey Palermo [MCP]

Vincent,
ClientID will always match the ID until the control is added to the Page
control hierarchy. Before the repeater binds, the controls aren't a part of
the Page's Controls collection yet. Try grabbing the ClientID on code
running in the ItemDataBound event handler. At this point, your control is
bound and exists on the page.

Best regards,
Jeffrey Palermo

"Vincent Mouton"
 
V

Vincent Mouton

Jeffrey said:
Vincent,
ClientID will always match the ID until the control is added to the Page
control hierarchy. Before the repeater binds, the controls aren't a part of
the Page's Controls collection yet. Try grabbing the ClientID on code
running in the ItemDataBound event handler. At this point, your control is
bound and exists on the page.

Best regards,
Jeffrey Palermo


Hi,

Yes indeed. That did it. Thanks a lot. Though I thought that an
ItemCreated event handler was only called after DataBinding, or rather,
while databinding.

Thanks again.

cheers,
v
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top