Ensuring unique Javascript identifiers in ASP.NET Web User Controls
<p>In my current project, I am creating a number of user controls, some of which include some custom Javascript for event handling on the client side. I am registering my event handlers using OnClientClick="function()" and the like.</p>

<p>Now, I'm wondering how to ensure that all Javascript function names are unique for each specific instance of the control, so I don't risk name conflicts between controls. I have thought about putting all functions inside a named object, like</p>

<pre><code>var &lt;%=ClientID%&gt;_Script {
  method1: function() { ...}
}
</code></pre>

<p>and then subscribing to events using something like</p>

<pre><code>OnClientClick="&lt;%=ClientID%&gt;_Script.methodName()"
</code></pre>

<p>It just seems like I can't but &lt;%= %>-expressions inside OnClient* attributes. I am therefore wondering; are there some "best practices" for doing this?</p>
