I'm using ASP.net 4.5.
I have a method like this:
protected void OnConfirm(object sender, EventArgs e)
{
// this function checks if an id exist in database
CheckIDExist(123);
//If Id exist I want to give the popup conform prompt to user
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Confirm", "Confirm();", true);
and then following code:
string[] arrReply =Request.Form["confirm_value"].Split(',');
string confirmValue = arrReply[arrReply.Length-1];
if (confirmValue == "Yes")
{
//populate the fields
int y=1;/
}
else
{
ClearSection1();
}
}
The problem is this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Confirm", "Confirm();", true); Does executed after all other codes. and not in the order expected.
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("There is a Survey that is open for thid CID. Do you wish to continue with existing Survey? If you press on Cancel a New Survey will be started.")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}