-1
這是我的代碼:的ImageButton結束div
<div runat="server" class="slide">
<img src="images/picto_detail.gif" onclick='<%# Eval("CampagneRappelId","hideshow(\"details{0}\")")%>' />
<div id='details<%# Eval("CampagneRappelId")%>' style="display: none;">
<asp:ImageButton runat="server" ID="DownloadPdf" ImageUrl="~/images/download.png" />
</div>
的JS 「隱藏顯示(格)」 就像是一個簡單的函數:
function hideshow(which) {
if (document.getElementById(which).style.display == "none")
document.getElementById(which).style.display = 'block';
else
document.getElementById(which).style.display = "none"
}
但我有與問題ASP:ImageButton的。當我點擊它時,我有隱藏在將文件下載到用戶計算機後面的代碼,但是當單擊該按鈕時,div「details」被關閉,顯示:none ...並且我無法找到爲什麼。
編輯:我已經測試過這樣的事情:
window.onload = function() {
document.getElementById("DownloadPdf").onclick = function (e) {
if (e && e.stopPropagation && someCriteriaToStopBubbling === true) {
e.stopPropagation();
}
else if (someCriteriaToStopBubbling === true) {
e = window.event;
e.cancelBubble = true;
}
}
};
感謝您的幫助。
這是一個很好的解決方案 – 2014-10-08 10:06:54
是的謝謝我知道,但我的隱藏/顯示功能沒問題。當我點擊asp:ImageButton時,通常需要留在屏幕上的div消失。 在我看來,這是用戶點擊按鈕時的回傳。 – Phobie 2014-10-08 10:08:24