I have a function that does some database update in asp.net. I'd like a modal popup to show a "success" message for just 5 seconds after my function has been called. In this case, the modal popup would not be triggered by any "TargetControl" but would show up for just 5 seconds once the function is done.
Thanks
You can't close standard javascript modal dialogs (alert, confirm,..) after a timeout. Only manual close works with them.
But, you can use jquery/UI dialog:
// timeOut in ms
function showMessageWithTiemout(message, timeOut){
// show dialog
var successDialog = $('<div>'+message+'</div>').dialog({modal: true});
//close it after 5 seconds
setTimeout(function(){ successDialog.dialog('close'); }, timeOut);
}
//usage:
showMessageWithTiemout('success!', 5000);
You have to manually call the show method on the panel like:
var pnl = $find("<%= modal.ClientID");
pnl.show();
So you can use window.setTimeout to call this:
window.setTimeout(function() { /* code */ }, 5000);
But it can't just happen very easily.
HTH.