Newbie here, so please go easy on me.
I need help with a confirmation message for the User. My JavaScript is supposed to trigger a Button click event when the User confirms, which will execute some back-end code. The back-end code then runs a JavaScript function that displays an alert to check if everything is working fine. However, I'm facing an issue where after confirming the first dialog, another one pops up. Upon confirming this second dialog, the code executes and the second JavaScript function alerts as expected. But, upon clicking 'Okay' on the alert, the process loops back to the first function causing a problem!
ASPX:
<script type = "text/javascript">
function ConfirmComputerOverwrite(Computer) {
if (confirm("Overwrite current computer " + Computer + " ?"))
{
}
else
{
}
document.getElementById("Test").click()
}
function allworkedout()
{
alert("success");
}
Code behind:
public string Computer = "";
protected void Page_Load(object sender, EventArgs e)
{
string Computer = "Computer1";
this.Computer = Computer;
StringBuilder sb = new StringBuilder();
sb.Append("ConfirmComputerOverwrite('" + Computer + "');");
ScriptManager.RegisterStartupScript(this, GetType(), "ConfirmComputerOverwrite", sb.ToString(), true);
}
protected void Test_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append("allworkedout();");
ScriptManager.RegisterStartupScript(this, GetType(), "allworkedoutID", sb.ToString(), true);
}
Grateful for any assistance!