I am currently working on this code :
<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>
Within the code, there is a JavaScript function called "hideshow(div)" which simply toggles the display of an element:
function hideshow(which) {
if (document.getElementById(which).style.display == "none")
document.getElementById(which).style.display = 'block';
else
document.getElementById(which).style.display = "none"
}
However, I have encountered an issue with the asp:ImageButton. Upon clicking it, the backend code triggers a file download for the user but it also hides the "details" div with display:none. I have been unable to determine the cause of this behavior.
EDIT: I have attempted the following solution:
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;
}
}
};
Your assistance in resolving this issue would be greatly appreciated. Thank you.