Hi,
Raise a confirmation message with yes no alert from markup of page aspx ASP.NET C#
Is it possible to raise a confirmation message with yes/no alert from markup of page aspx?
I need to raise the message confirm or not from the JavaScript function when the user try file download.
Is there any native way to do this?
Hope someone can give me an idea how to solve this.
Markup
<div class="container">
<asp:ImageButton runat="server"
ID="imgxls" Visible="true"
OnClick="imgxls_Click"
OnClientClick="jsShowHideProgress2();"
ToolTip="Download"
ImageUrl="/aspnet/img/download.gif" />
</div>
<div class="pure-u-1 pure-u-md-1-3">
<img style="display: none; margin-left: auto; margin-right: auto;"
id="imgloadinggif2"
src="/aspnet/img/ajax-loader.gif"
alt="loading.." />
</div>
Javascript
function jsShowHideProgress2() {
setTimeout(function () { document.getElementById('imgloadinggif2').style.display = 'block'; }, 200);
deleteCookie();
var timeInterval = 200; // milliseconds (checks the cookie for every half second )
var loop = setInterval(function () {
if (IsCookieValid()) { document.getElementById('imgloadinggif2').style.display = 'none'; clearInterval(loop) }
}, timeInterval);
}
// cookies
function deleteCookie() {
var cook = getCookie('ExcelDownloadFlag');
if (cook != "") {
document.cookie = "ExcelDownloadFlag=; Path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC";
}
}
function IsCookieValid() {
var cook = getCookie('ExcelDownloadFlag');
return cook != '';
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}