Jieha Lee

Jieha Lee

  • 1.8k
  • 151
  • 4.2k

Popup response linked with C# function

Mar 15 2018 10:01 PM
I'm trying to call a JavaScript function with a popup. If user click on "Ok", it calls a C# function. In my case, the pop up is functioning but when I click "Ok" it not redirect to C# function. How to fix this?
<script type = "text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
var noTel = document.getElementById("offcell").value;
var msg = document.getElementById("textarea-1").value;
alertify.confirm('PREVIEW MESSAGE', "To:" + noTel + "<br>Message:" + msg, function (e) {
confirm_value.value = "Yes";
}, null).set('labels', { ok: 'Confirm', cancel: 'Cancel' });
The button that call JavaScript:
<asp:button runat="server" OnClick="Button1_Click" style="margin: 15px 22px;" type="submit" id="Button14" value="Login" Text="Send" CssClass="send blockbtn" name="send" OnClientClick="Confirm(); return false;"></asp:button>
The C# function :
protected void Button1_Click(object sender, EventArgs e)
if (Request.Form["confirm_value"] == "Yes")
//ClientScript.RegisterStartupScript(this.GetType(), "script", "document.location.href='/default.aspx';", true);

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (2)