我查看了网络和我的代码,但我无法找到问题。请帮忙。我的代码如下。我创建了一些链接按钮,它们调用回发到后端,触发javascript来禁用/启用链接按钮。不幸的是,我无法这样做。它甚至可以通过javascript完成吗?知道为什么吗?
请帮忙......谢谢
<ul class="nav nav-tabs">
<li role="presentation" class="active" ID="tab1"><asp:LinkButton ID="tab1Link" runat="server"><strong>Basic</strong></asp:LinkButton></li>
<li role="presentation" ID="tab2"><asp:LinkButton ID="tab2Link" runat="server"><strong>Details+</strong></asp:LinkButton></li>
<li role="presentation" ID="tab3"><asp:LinkButton ID="tab3Link" runat="server"><strong>Location</strong></asp:LinkButton></li>
<li role="presentation" ID="tab4"><asp:LinkButton ID="tab4Link" runat="server"><strong>Media</strong></asp:LinkButton></li>
<li role="presentation" ID="tab5"><asp:LinkButton ID="tab5Link" runat="server" OnClientClick="javascript: tabSeq('tab5', 5)"><strong>Summary</strong></asp:LinkButton></li>
</ul>
function tabSeq(activeTab, numberOfTabs)
{
var tabOKVal = "";
for (var i = 1; i <= numberOfTabs; i++)
{
document.getElementById('tab'+ i).className = "";
document.getElementById('tab'+ i+"Div").style.display = 'none';
tabOKVal = document.getElementById('tabOK'+ i).value;
if(tabOKVal == "OK" && i != numberOfTabs)
{
document.getElementById('tab' + (i+1) + 'Link').disabled = "";
document.getElementById('tab' + (i+1) + 'Link').style.color = '#3498DB';
}
}
document.getElementById('tab5Link').disabled = "disabled";
document.getElementById(activeTab).style.color = '#555555';
document.getElementById(activeTab).className = "active";
document.getElementById(activeTab+"Div").style.display = '';
}
答案 0 :(得分:0)
onload = function(){
tabSeq('tab5', 5)
}
function tabSeq(activeTab, numberOfTabs)
{
//other stuff goes here
document.getElementById('tab5Link').disabled = true;
document.getElementById(activeTab).style.color = '#555555';
document.getElementById(activeTab).className = "active";
document.getElementById(activeTab+"Div").style.display = '';
}
<ul class="nav nav-tabs">
<li role="presentation" class="active" ID="tab1"><asp:LinkButton ID="tab1Link" runat="server"><strong>Basic</strong></asp:LinkButton></li>
<li role="presentation" ID="tab2"><asp:LinkButton ID="tab2Link" runat="server"><strong>Details+</strong></asp:LinkButton></li>
<li role="presentation" ID="tab3"><asp:LinkButton ID="tab3Link" runat="server"><strong>Location</strong></asp:LinkButton></li>
<li role="presentation" ID="tab4"><asp:LinkButton ID="tab4Link" runat="server"><strong>Media</strong></asp:LinkButton></li>
<li role="presentation" ID="tab5"><button ID="tab5Link" runat="server" OnClientClick="javascript: tabSeq('tab5', 5)"><strong>Summary</strong></button></li>
</ul>
答案 1 :(得分:0)
LinkButtons是ASP.NET服务器控件,您在设计时看不到控件ID值。
您可以按如下方式重写js代码:
document.getElementById("<%= tab5Link.ClientID %>").disabled = "disabled";
请注意,只有JS代码在同一页面上才能完成。