我正在尝试在客户端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>
当我在webform中使用它时,我收到以下错误
Microsoft JScript运行时错误:'AjaxControlToolkit'未定义
错误发生在这一行:
$create(AjaxControlToolkit.TabPanel, { "headerTab": $get(header.id) }, null, { "owner": tabContainerID }, $get(body.id));
我安装了控件工具包,但我无法弄清楚我需要做些什么才能访问js运行时库。 我是否需要下载源代码并引用js文件,还是需要其他任何先决条件?非常感谢任何帮助
谢谢
保
答案 0 :(得分:1)
最后,这是因为microsoft将类名更改为Sys.Extended.UI.TabPanel。感谢帖子
$create(Sys.Extended.UI.TabPanel, { "headerTab": _spanTab, "ownerID": tabContainerID, "wasLoadedOnce": false }, null, { "owner": tabContainerID }, body); //$get(body.id));