javascript - C# confirm() Function Browser Refresh Issue -
i have c# program, uses javascript confirm() function create yes/no alert.
the issue i'm having is:
- i click "yes" on pop-up , program executes.
- now, when refresh browser, "confirm form re-submission" message appears, , if click on "continue" same yes/non pop-up appears again, instead of reloading page. , i'm forced select yes or no again.
javascript:
function confirm() { var confirm_value = document.createelement("input"); confirm_value.type = "hidden"; confirm_value.name = "confirm_value"; if (confirm("are sure want continue?")) { confirm_value.value = "yes"; } else { confirm_value.value = "no"; } document.forms[0].appendchild(confirm_value); } c#:
public void onconfirm(object sender, eventargs e) { try { string confirmvalue = request.form["confirm_value"]; if (confirmvalue == "yes") { this.page.clientscript.registerstartupscript(this.gettype(), "alert", "alert('you selected yes.')", true); } else { this.page.clientscript.registerstartupscript(this.gettype(), "alert", "alert('you selected no.')", true); } } catch (exception ex) { exceptionlabel.text = (ex.message); } }
Comments
Post a Comment