如何使用asp.net中的甜蜜警报进行警报和重定向

时间:2018-11-19 09:40:54

标签: javascript asp.net sweetalert

ScriptManager.RegisterStartupScript(this, this.GetType(), 
"alert", 
"alert('User details saved successfully');window.location ='frmDisplayUsers.aspx';", 
true);

2 个答案:

答案 0 :(得分:1)

您需要在页面顶部的SweetAlert库中添加参照资源:

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

然后您需要将代码更改为此:

ScriptManager.RegisterStartupScript(this, this.GetType(), 
"alert",
"swal('User details saved successfully').then((value) => { window.location ='frmDisplayUsers.aspx'; });", 
true);

答案 1 :(得分:0)

ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "swal('Done !!!','User details saved successfully','success').then((value) => { window.location ='frmDisplayUsers.aspx'; });", true);

这就是我想要的.....