我有以下JS代碼顯示/隱藏按鈕(必須這樣做,請不要說這樣做)。javascript代碼後面的值
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequestHandle);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandle);
function beginRequestHandle(sender, Args) {
document.getElementById("ltInstructions").style.visibility = "hidden";
document.getElementById("btnSubmit").style.visibility = "hidden";
document.getElementById("btnToExcel").style.visibility = "hidden";
}
function endRequestHandle(sender, Args) {
if(<%=resultsCount %> > 0)
{
document.getElementById("ltInstructions").style.visibility = "visible";
document.getElementById("btnSubmit").style.visibility = "visible";
document.getElementById("btnToExcel").style.visibility = "visible";
}
else
{
document.getElementById("results").innerHTML = "<br><b><center><font size=20>No results found, please try again.</b></font></center>";
}
}
問題是<%=resultsCount %>
它獲取在代碼初始化爲0的後面,然後在後面Timer_Tick方法更新。上面的Js總是把它取爲0.
如何讓JS把它作爲正確的值?
謝謝。這已經修復了:) – user1468537 2012-07-09 09:46:07
不客氣。 – Adil 2012-07-09 09:49:19