Get clientid in user control from external javascript file
Posted
by Giorgi
on Stack Overflow
See other posts from Stack Overflow
or by Giorgi
Published on 2010-03-23T12:58:24Z
Indexed on
2010/03/23
13:43 UTC
Read the original article
Hit count: 347
Hello,
I am developing a user control (ascx) in ASP.NET which uses javascript for manipulating controls. Currently the javascript code is inlined and uses <%= somecontrol.ClientID %>
to get the control it needs.
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 this and this 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 <%= ClientId %>
in the name of array that holds items then I will have the same problem as I am trying to solve.
Any ideas?
© Stack Overflow or respective owner