[英]set tabcontainer active tab using javascript
我正在使用以下javascript函数来设置活动的asp.net标签。 该提示代码始终返回CurrentTab为“ null”。 任何人都可以帮助我解决我的问题。
function SetActiveTab2(tabNumber) {
try {
var CurrentTab = $find('<%#cust_tab.ClientID%>');
var CurrentTab = document.getElementById('<%=cust_tab.ClientID%>');
//Second line return the error The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
CurrentTab.set_activeTabIndex(parseInt(tabNumber));
}
catch (e) {
alert('An error has occurred: ' + e.message)
return false;
}
}
删除它: var CurrentTab = document.getElementById('<%=cust_tab.ClientID%>');
并按如下方式修改上一行: var CurrentTab = $find('<%= cust_tab.ClientID %>');
当您想通过其ID获取元素时,必须在其开头加上#号。
var CurrentTab = document.getElementById('#<%=cust_tab.ClientID%>');
也许这就是解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.