CustomControl for Team WebAccess --> jQuery doesnt work
<p>I recently ran into some similar issue I think.
I am developing a custom control for Team WebAccess 2010: The MultiValueControl for the browser. To achieve the very same experience as the MultiValueControl of the witcontrolsuite. (http://witcustomcontrols.codeplex.com/wikipage?title=Multivalue%20control&amp;referringTitle=Home)</p>

<p>Therefore I am using an asp.net server control with a listbox (which is rendered as a html ) along with the following jquery drowdownchecklist (http://code.google.com/p/dropdown-check-list/)</p>

<p>the servercontrol looks like the following</p>

<pre><code>   using System.Linq;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace CodePlex.WitCustomControls.WebAccess.MultiValueControl
    {
        [DefaultProperty("Text")]
        [ToolboxData("&lt;{0}:MultiValueControl runat=server&gt;&lt;/{0}:MultiValueControl&gt;")]
        public class MultiValueControl : WebControl
        {
            public ListBox MyListBox { get; set; }

            protected override void CreateChildControls()
            {
                base.CreateChildControls();

                MyListBox = new ListBox();
                MyListBox.SelectionMode = ListSelectionMode.Multiple;
                MyListBox.Items.Add(new ListItem("abcd 1"));
                MyListBox.Items.Add(new ListItem("abcd 2"));
                MyListBox.Items.Add(new ListItem("abcd 3"));
                MyListBox.Items.Add(new ListItem("abcd 4"));
                MyListBox.Items.Add(new ListItem("abcd 5"));

                this.Controls.Clear();
                this.Controls.Add(MyListBox);
            }

            [Bindable(true)]
            [Category("Appearance")]
            [DefaultValue("")]
            [Localizable(true)]
            public string Text
            {
                get
                {
                    String s = (String)ViewState["Text"];
                    return ((s == null) ? String.Empty : s);
                }

                set
                {
                    ViewState["Text"] = value;
                }
            }

   protected override void OnPreRender(EventArgs e)
            {
                base.OnPreRender(e);

                string resourceName1 = "WebApplication1.embedded.jquery-1.4.2.min.js";
                string resourceName2 = "WebApplication1.embedded.jquery-ui-1.8.4.custom.min.js";
                string resourceName3 = "WebApplication1.embedded.ui.dropdownchecklist.js";

                ClientScriptManager cs = this.Page.ClientScript;
                var t = typeof(MultiValueControl);

                cs.RegisterClientScriptResource(t, resourceName1);
                cs.RegisterClientScriptResource(t, resourceName2);
                cs.RegisterClientScriptResource(t, resourceName3);

                string csslink = "&lt;link href='"
                    + Page.ClientScript.GetWebResourceUrl(t, "WebApplication1.embedded.ui.dropdownchecklist.standalone.css")
                    + "' rel='stylesheet' type='text/css' /&gt;";
                var include = new LiteralControl(csslink);
                this.Page.Header.Controls.Add(include);

                string csslink2 = "&lt;link href='"
                    + Page.ClientScript.GetWebResourceUrl(t, "WebApplication1.embedded.ui.dropdownchecklist.themeroller.css")
                    + "' rel='stylesheet' type='text/css' /&gt;";
                var include2 = new LiteralControl(csslink2);
                this.Page.Header.Controls.Add(include);

                var csType = typeof(MultiValueControl);
                var csName = "MultiValueControl" + MyListBox.ClientID;
                // Check to see if the client script is already registered.
                if (!cs.IsClientScriptBlockRegistered(csType, csName))
                {
                    StringBuilder csText = new StringBuilder();
                    csText.Append("&lt;script type=\"text/javascript\"&gt;");
                    //we need to write the code the following way
                    csText.Append("(function($) { $(document).ready(function() {$(\"#" + this.MyListBox.ClientID + "\").dropdownchecklist();}); })(jQuery);");
                    //does not work as $ sign is not associated with jQuery in Team WebAccess!
                    //csText.Append(" $(document).ready(function() {$(\"#" + this.MyListBox.ClientID + "\").dropdownchecklist();});");
                    csText.Append("&lt;/script&gt;");
                    cs.RegisterClientScriptBlock(csType, csName, csText.ToString());

                }
            }
        }
    }
</code></pre>

<p>As you can see, I inject the scripts (which are embedded in the controls assembly) into the output page in the pre-render step.</p>

<p>When I run all this on an asp.net application on my local computer (I created it to prototype my solution) it works perfectly...</p>

<p>However that control does not work with Team WebAccess 2010, as I get the error message <strong>'jQuery' is undefined</strong></p>

<p>However when I look at my page, I can definetly see, that the three scripts I inject are just perfectly well added just before the script that throws the error:</p>

<pre><code>    &lt;script src="/tfs/web/WebResource.axd?d=yGr4pF28N1gYPBSvcQ65PxwkQdtFV1bc0SJjY2M7nTK9BloSmvQxu8btRw7YDdXsjbAwSZPJBiIDI-3FSC7yFCXHjuvhkhaTAlTv2uOnOhR_y_2fLK1ahIdVYiXjEjDT2ZEI9_ozHhoJqICZykZo_rBCIDp5h7Y8v6-zWJJDJoqIIHI47YpQDhsE4-_UcYV6b6G-Cgr8MWH9AEP7CtK7Ie6wWCU1&amp;amp;t=634306043180265615" type="text/javascript"&gt;&lt;/script&gt;
        &lt;script src="/tfs/web/WebResource.axd?d=9iAfN71_Hpv7igrtbh4h9pBAMBHXqUC1cX5cjkAEr1PglPvi4Uo5KLOC6tuHzMyGkpHEeBXbVeIX_NGIiKlHPSNlOjw75DksE2F-2NMVlIXoEB4uVTvyTwvt1TM3S2AGLY13hLPmM-SW12g3ZGU28PC23Vx_aYAFWSco6hgPTcCBOPuw4nSNSI72kgVuMwBjhzjxVbbzhdGLxrSAodBH5g7PATsuAN7CHE8vmi_pk9f8mW-50&amp;amp;t=634306043180265615" type="text/javascript"&gt;&lt;/script&gt;
        &lt;script src="/tfs/web/WebResource.axd?d=c_BidQPb2wjtuw09st9ilCtRhA4VEjgNgJgr0VlFIRdKYP2UK1AqWS8Mo3AEiDU_MMCZkwjMVa1tTKg9UlpFoCqxCzKUhCK7Moou4ywZ74S0FJvdrcJ1cGbqtZnxrfUBLbN8_iahrG2A9Fq55up3o6R2_SlFU4d_gb_4fBXnticOG8Bl4JCbq7F2PnG-rw0fTiNwGDMwZFv1RvNJerUGYo_0Wuw1&amp;amp;t=634306043180265615" type="text/javascript"&gt;&lt;/script&gt;
        &lt;script type="text/javascript"&gt;(function($) { $(document).ready(function() {$("#ctl00_c_we_ctl47_ctl00").dropdownchecklist();}); })(jQuery);&lt;/Script&gt;

    The following is the source of the page (up to my injected scripts) that does not work. (of course I dummied the fqdn name of the server ;-))



    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;&lt;title&gt;
    New Change Request: - Team Web Access
&lt;/title&gt;
    &lt;base target="_self" /&gt;

&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]&gt;
&lt;/script&gt;
&lt;script src="/tfs/web/WebResource.axd?d=fLgM8VwLkwzQwVHlt0I3zfY4k-15sHec44H9BY54wjS_v_rJDRkLrbhLIvED-zHvir1koHstEWBv_Erm3BGVmScM6OA1&amp;amp;t=634210436612724343" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
//&lt;![CDATA[var JSConfig ={"showBrowserToolbar":true};//]]&gt;&lt;/script&gt;
&lt;script src="/tfs/web/Resources/Scripts/WindowHelpers.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/tfs/web/Resources/Scripts/DocumentService.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/tfs/web/ScriptResource.axd?d=DUMMYVALUE"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
$jslimg("imga8521f38",["/tfs/web/App_Themes/Default/Images/h-progress.gif","/tfs/web/App_Themes/Default/Images/spinner.gif","/tfs/web/App_Themes/Default/Images/tmih.gif"]);//]]&gt;
&lt;/script&gt;
&lt;script src="/tfs/web/Resources/Scripts/WindowToolbar.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/tfs/web/Resources/Scripts/SearchHelper.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
$new(windowToolbar,"ctl00_wtb",["ctl00$wtb",{"pguid":"e591d5c5-c3bd-4431-81cc-62b4fc5a6b81"}]);
//]]&gt;
&lt;/script&gt;
&lt;script src="/tfs/web/Resources/Scripts/EditWorkItem.js" type="text/javascript"&gt;&lt;/script&gt;

....

&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
$jsreg("cd326c372",{"changeCallbackEventName":"FieldChanged","numberFormat":"None"});
$jsreg("c384acf1b",{"dropCount":8,"minDropPanelWidth":0,"maxDropPanelWidth":0,"notAllowedBGColor":"#FFFFCC","allowedBGColor":"","textBoxClass":"tswa-text-box","textBoxDisabledClass":"tswa-text-box-disabled","dropPanelClass":"tswa-font tswa-dropdowncanvas","listItemClass":"tswa-listitem","listItemHoverClass":"tswa-listitemhover","listItemSelectedClass":"tswa-listitemselected","listItemDisabledClass":"tswa-listitemdisabled","decimalChar":","});
$jsreg("c569d08c7",[]);
$new(editableDropDown,"ctl00_c_we_ctl04_wc_val",[5,cd326c372,null,c384acf1b,null,c569d08c7,c569d08c7,c569d08c7,null,"",null,""]);
//]]&gt;
&lt;/script&gt;
&lt;script src="/tfs/web/WebResource.axd?d=yGr4pF28N1gYPBSvcQ65PxwkQdtFV1bc0SJjY2M7nTK9BloSmvQxu8btRw7YDdXsjbAwSZPJBiIDI-3FSC7yFCXHjuvhkhaTAlTv2uOnOhR_y_2fLK1ahIdVYiXjEjDT2ZEI9_ozHhoJqICZykZo_rBCIDp5h7Y8v6-zWJJDJoqIIHI47YpQDhsE4-_UcYV6b6G-Cgr8MWH9AEP7CtK7Ie6wWCU1&amp;amp;t=634306043180265615" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/tfs/web/WebResource.axd?d=9iAfN71_Hpv7igrtbh4h9pBAMBHXqUC1cX5cjkAEr1PglPvi4Uo5KLOC6tuHzMyGkpHEeBXbVeIX_NGIiKlHPSNlOjw75DksE2F-2NMVlIXoEB4uVTvyTwvt1TM3S2AGLY13hLPmM-SW12g3ZGU28PC23Vx_aYAFWSco6hgPTcCBOPuw4nSNSI72kgVuMwBjhzjxVbbzhdGLxrSAodBH5g7PATsuAN7CHE8vmi_pk9f8mW-50&amp;amp;t=634306043180265615" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/tfs/web/WebResource.axd?d=c_BidQPb2wjtuw09st9ilCtRhA4VEjgNgJgr0VlFIRdKYP2UK1AqWS8Mo3AEiDU_MMCZkwjMVa1tTKg9UlpFoCqxCzKUhCK7Moou4ywZ74S0FJvdrcJ1cGbqtZnxrfUBLbN8_iahrG2A9Fq55up3o6R2_SlFU4d_gb_4fBXnticOG8Bl4JCbq7F2PnG-rw0fTiNwGDMwZFv1RvNJerUGYo_0Wuw1&amp;amp;t=634306043180265615" type="text/javascript"&gt;&lt;/script&gt;&lt;script type="text/javascript"&gt;(function($) { $(document).ready(function() {$("#ctl00_c_we_ctl49_ctl00").dropdownchecklist();}); })(jQuery);&lt;/script&gt;
&lt;script type="text/javascript"&gt;(function($) { $(document).ready(function() {$("#ctl00_c_we_ctl52_ctl00").dropdownchecklist();}); })(jQuery);&lt;/script&gt;
</code></pre>

<p>I just have no more clues what I can do! <strong>Please HELP!!</strong></p>
