title: Get clientid in user control from external javascript file
body: <p>I am developing a user control (ascx) in ASP.NET which uses javascript for manipulating controls. Currently the javascript code is inlined and uses <code>&lt;%= somecontrol.ClientID %&gt;</code> to get the control it needs.</p>
  
  <p>I want to put the javascript file in external file but from external file I cannot use the above syntax for retrieving controls. I have read about possible solutions in <a href="https://stackoverflow.com/questions/1861103/how-can-i-access-server-controls-from-my-external-javascript-file/1861211#1861211">this</a> and <a href="https://stackoverflow.com/questions/2078392/can-i-count-on-ctl00-pageplaceholder-myid-staying-the-same/2078420#2078420">this</a> answers but the problem is that the user control can be placed multiple times on page. This means that the Controls array (mentioned in the answers) will be rendered several times with different items. As a result the script will not be able to retrieve the id it needs. If I put <code>&lt;%= ClientId %&gt;</code> in the name of array that holds items then I will have the same problem as I am trying to solve.</p>
  
  <p>Any ideas?</p>