I am dynamically adding a jQuery multiselect control onto a page like this:
var captionCell = new HtmlTableCell { InnerHtml = control.Caption };
var inputCell = new HtmlTableCell();
inputCell.Controls.Add(inputControl);
var row = new HtmlTableRow();
row.Cells.Add(captionCell);
row.Cells.Add(inputCell);
tbl.Rows.Add(row);
And building my javascript string like this:
StringBuilder sb = new StringBuilder();
sb.AppendLine("<script type=\"text/javascript\">");
sb.AppendLine("var $callback = $(\"#callback\");");
sb.AppendLine("$(document).ready(function () {");
sb.Append("$(\"#");
sb.Append(multiSelectControl.ClientID);
sb.AppendLine("\").multiselect(");
sb.AppendLine("{");
sb.AppendLine("show: \"fade\",");
sb.AppendLine("hide: \"fade\",");
sb.AppendLine("click: function (event, ui){");
sb.AppendLine("$callback.text(ui.text + ' ' + (ui.checked ? 'checked' : 'unchecked'));");
sb.AppendLine("},");
sb.AppendLine("});");
sb.AppendLine("});");
sb.AppendLine("</script>");
Then adding the script to the page like this:
ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "CreateControl" + inputControl.ClientID,
sb.ToString(), false);
But im getting the following error when trying to do this:
Microsoft JScript runtime error: Object doesn’t support this property or method
Please assist guys.
Thanks in advance.

I solved this by creating a user control, and when I need to use the script above I just loaded the user control.
Solved everything and works really well.