Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在客户端发出警报消息后继续执行代码_C#_Javascript - Fatal编程技术网

C# 在客户端发出警报消息后继续执行代码

C# 在客户端发出警报消息后继续执行代码,c#,javascript,C#,Javascript,我必须使用WebAppApplication发送邮件。一切正常,但如果未选择附件,我必须显示确认消息。在该确认框中,单击“确定”时,代码应继续执行,单击“取消”按钮时,代码应返回 这是我的密码 代码隐藏 protected void btnSend_Click(object sender, EventArgs e) { string str = "Are you sure, you want to proceed without attachment?"; this.ClientScr

我必须使用WebAppApplication发送邮件。一切正常,但如果未选择附件,我必须显示确认消息。在该确认框中,单击“确定”时,代码应继续执行,单击“取消”按钮时,代码应返回

这是我的密码

代码隐藏

 protected void btnSend_Click(object sender, EventArgs e)
  {
string str = "Are you sure, you want to proceed without attachment?";  
this.ClientScript.RegisterStartupScript(typeof(Page), "Popup", "ConfirmApproval('" + str + "');", true);
...Send mail code goes here
}
ASPX


它工作正常,即单击“确定”按钮时,将显示警报“执行代码”。我不想显示警报,而是想继续执行代码。我们将如何从客户端执行此操作??

您需要使用
确认(“执行代码”)
而不是“警报”。希望有帮助:)

试试这个代码

protected void Page_Load(object sender, EventArgs e)
{
    btnSend.Attributes.Add("onclick","return confirm('execute code');");
}

我向你展示了一种野蛮的方法

将该代码放在您创建的任何网页的页面加载(发件人,e)中。现在通过XHR调用它

(这可能是一个糟糕的回答)

var agreed = confirm("execute code");

if(agreed) {
    //do something
} else {
    return false;
}
protected void Page_Load(object sender, EventArgs e)
{
    btnSend.Attributes.Add("onclick","return confirm('execute code');");
}