Skip to content Skip to sidebar Skip to footer

Asp Controls Id Generation Inside Repeater

I define some controls inside repeater itemtemplate, the problem is with the Id that are generated automatically. This is my page:

Solution 1:

Well as to why this is happening I'm not real sure. I suspect it may know that you used the ClientID so it didn't change it according to the naming container when the HTML was rendered.

As to what you can do to fix the problem, don't pass the ID to the javascript function. When an event fires in javascript the event object will be passed to the function for Firefox, IE has an explicit windows.event object. The event object will have a reference to the object that fired the event which you can then use to access the ID, but my guess is you were going to use the ID to get a reference to the element anyway.

Solution 2:

An odd problem, can't say why this is happening, BUT... try moving this code to ItemDataBound instead of ItemCreated, I think you'll have more luck. I've written code exactly like this, but using OnItemDataBound and not had a problem.

Theoretically, any control inside a NamingContainer should get a unique ID, so there is definitely something fishy going on here.

Post a Comment for "Asp Controls Id Generation Inside Repeater"