<p>i have a control that is organized like this</p>

<p><img src="https://dl-web.getdropbox.com/get/jsstructure.GIF?w=faef1ed3" alt="alt text"></p>

<p>and i want to have the javascript registered on the calling master pages, etc, so that anywhere this control folder is dropped and then registered, it will know how to find the URL to the js.</p>

<p>Here is what i have so far (in the user control )</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if(!Page.IsClientScriptBlockRegistered("jqModal"))
        Page.ClientScript.RegisterClientScriptInclude("jqModal", ResolveClientUrl("~js/jqModal.js"));
    if (!Page.IsClientScriptBlockRegistered("jQuery"))
        Page.ClientScript.RegisterClientScriptInclude("jQuery", ResolveClientUrl("~/js/jQuery.js"));
    if (!Page.IsClientScriptBlockRegistered("tellAFriend"))
        Page.ClientScript.RegisterClientScriptInclude("tellAFriend", ResolveClientUrl("js/tellAFriend.js"));
}
</code></pre>

<p>Any ideas?</p>

You can use a helper class with static method:
```
```
public static class PageHelper {
    public static void RegisterClientScriptIfNeeded( Page page, string key, string url ) {
        if( false == page.IsClientScriptBlockRegistered( key )) {
            page.ClientScript.RegisterClientScriptInclude( key , ResolveClientUrl( url ));
        }
    }
}
```
```
or you can have a similar instance method in some base class for page/webcontrol/usercontrol, which will do the same thing.