1

我正在尝试在客户端 javascript 中操作 ajaxcontroltoolkit 选项卡容器。我找到了以下示例代码:

<script type="text/javascript">
    var i = 3;
    function createnew() {


        CreateNewTabPanel('TabContainer1', 'TabPanel' + i, 'TabPanel' + i, 'TabPanel' + i);
        i++;




    }


    function CreateNewTabPanel(tabContainerID, tabPanelID, headerText, bodyText) {
        //create header
        var header = document.createElement('span');
        header.id = "__tab_" + tabContainerID + tabPanelID;
        header.innerHTML = headerText;
        $get(tabContainerID + "_header").appendChild(header);


        //create content
        var body = document.createElement('div');
        body.id = tabContainerID + "_" + tabPanelID;
        body.style.display = "none";
        body.style.visibility = "hidden";
        body.innerHTML = bodyText;
        body.cssClass = "ajax__tab_panel";
        $get(tabContainerID + "_body").appendChild(body);




        $create(AjaxControlToolkit.TabPanel, { "headerTab": $get(header.id) }, null, { "owner": tabContainerID }, $get(body.id));




    }




</script>
<body>
    <form id="form1" runat="server">
    <ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
<span id="mes"></span><br />
<span id="mes1"></span>
    <ajaxToolkit:TabContainer runat="server" ID="TabContainer1"   >
            <ajaxToolkit:TabPanel runat="server" ID="TabPanel1" HeaderText="TabPanel1">
                <HeaderTemplate>
                    TabPanel1
                </HeaderTemplate>
            <ContentTemplate>
                TabPanel1
            </ContentTemplate>
        </ajaxToolkit:TabPanel>
                    <ajaxToolkit:TabPanel runat="server" ID="TabPanel2" HeaderText="TabPanel2">
            <ContentTemplate>
                TabPanel2
            </ContentTemplate>
        </ajaxToolkit:TabPanel>
    </ajaxToolkit:TabContainer>


    <input type="button" onclick="createnew()" value="create a new pane" />


    </form>
</body>

当我在网络表单中使用它时,出现以下错误

Microsoft JScript 运行时错误:“AjaxControlToolkit”未定义

错误发生在这一行:

$create(AjaxControlToolkit.TabPanel, { "headerTab": $get(header.id) }, null, { "owner": tabContainerID }, $get(body.id)); 

我安装了控制工具包,但我不知道我需要做什么才能访问 js 运行时库。我需要下载源代码并引用 js 文件,还是需要任何其他先决条件?任何帮助是极大的赞赏

谢谢

保罗

4

1 回答 1

1

最后这是因为微软将类名更改为 Sys.Extended.UI.TabPanel。谢谢你的帖子

$create(Sys.Extended.UI.TabPanel, { "headerTab": _spanTab, "ownerID": tabContainerID, "wasLoadedOnce": false }, null, { "owner": tabContainerID }, body); //$get(body.id));
于 2013-04-18T17:17:51.430 回答