C# 在客户端发出警报消息后继续执行代码
我必须使用WebAppApplication发送邮件。一切正常,但如果未选择附件,我必须显示确认消息。在该确认框中,单击“确定”时,代码应继续执行,单击“取消”按钮时,代码应返回 这是我的密码 代码隐藏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
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');");
}