Jieha Lee

Jieha Lee

  • 1.7k
  • 151
  • 3.1k

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";
document.forms[0].appendChild(confirm_value);
//__doPostBack('sms');
}, null).set('labels', { ok: 'Confirm', cancel: 'Cancel' });
}
</script>
 
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")
{
Response.Redirect("Default.aspx");
//ClientScript.RegisterStartupScript(this.GetType(), "script", "document.location.href='/default.aspx';", true);
}
}

Answers (2)