I need to display a confirmation dialog under certain conditions and then proceed based on the user's response of yes or no. I attempted the following approach.
Here is the code in aspx:
<script type="text/javascript>
function ShowConfirmation() {
if (confirm("Employee already exists. Continue?") == true) {
document.getElementById("hdn_empname").value = 1;
}
}
</script>
<asp:HiddenField ID="hdn_empname" runat="server" />
And here is the code in cs:
if (reader2.HasRows)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "showAlert", "ShowConfirmation();", true);
}
else
{
hdn_empname.Value ="1";
}
if ((hdn_empname.Value)=="1")
{
//execute some specific code
}
However, during debugging, hdn_empname
shows value=""
.
Could anyone assist me with this issue?
Thank you in advance.