[英]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.