Needed to have a button click on a Return Confirm to do an operation, and my button wasn't being clicked.
Turns out it was because I was having conflicting Ajax requests, got around it using this.
Turns out it was because I was having conflicting Ajax requests, got around it using this.
VB Code:
RadScriptManager.RegisterStartupScript(Page, GetType(String), "confirm", "ProcessAnyway('" & btnProcessAnyway.ClientID & "','" & strMessage & "');", True)
JavaScript Code:
function ProcessAnyway(strButtonIDToClick, strConfirmText)
{
var prm = Sys.WebForms.PageRequestManager.getInstance();
//see if there is an Ajax request in progress.
if (prm.get_isInAsyncPostBack())
{
//wait 1/4 second and try again (recursive)
setTimeout(function() { ProcessAnyway(strButtonIDToClick, strConfirmText) }, 250);
}
else
{
//Yay, not AsyncPostBack run code
ProcessAnywayAgain(strButtonIDToClick, strConfirmText);
}
}
function ProcessAnywayAgain(strButtonIDToClick, strConfirmText)
{
if (confirm(strConfirmText))
{
document.getElementById(strButtonIDToClick).click();
}
}
No comments:
Post a Comment