Is there a better way to get ClientID's into external JS files?
<p>I know this has been asked before, but I've found a different way to get references to controls in external JS files but I'm not sure how this would go down in terms of overall speed.</p>

<p>My code is</p>

<pre><code>public static void GenerateClientIDs(Page page, params WebControl[] controls) {

        StringBuilder script = new StringBuilder();
        script.AppendLine("&lt;script type=\"text/javascript\"&gt;");

        foreach (WebControl c in controls) {
            script.AppendLine(String.Format("var {0} = '#{1}';", c.ID, c.ClientID));
        }

        script.AppendLine("&lt;/script&gt;");

        if (!page.ClientScript.IsClientScriptBlockRegistered("Vars")) {
            page.ClientScript.RegisterClientScriptBlock(page.GetType(), "Vars", script.ToString());
        }
    }
</code></pre>

<p>This was I can reference the id of the aspx page in my JS files.</p>

<p>Can anyone see any drawbacks to doing things this way? I've only started using external JS files. Before everything was written into the UserControl itself.</p>
