Hi all,
I have managed with this by defining a server side property 'InstanceName' in the UserControl. I explicitly set its value (the same as the ID) when creating the control instance.
<MYTAGPREFIX:MYCONTROLNAME Runat="server" (...) ID="someID" InstanceName="someID"></MYTAGPREFIX:MYCONTROLNAME>
In the client side I use document.getElementById(<%= InstanceName %> + '_' + myElementName) instead of myElementName.
Another way is to read the prefix from the name of a client control:
function GetNamePrefix(control)
{
(...)
var posEnd = control.name.indexOf(":");
return control.name.substring(0, posEnd);
}
The prefix will be the same for every control in the container. You can store it and use it everywhere: document.getElementById(prefix + '_' + myElementName)
The full thing is a little tricky and seems quite inefficient, but it mostly works. However there are a lot of specific cases where I had to look for another workarounds as this solution was not working. The most difficult situation is when there are several instances of the same User Control in a container document. I'm not sure it is worth the effort.
Best regards,
Diana