如何在 ASP.NET 中使用 Sweet Alert 进行警报和重定向

问题描述 投票:0回答:3
ScriptManager.RegisterStartupScript(this, this.GetType(), 
"alert", 
"alert('User details saved successfully');window.location ='frmDisplayUsers.aspx';", 
true);
javascript asp.net sweetalert
3个回答
1
投票

您需要在页面的 head 部分添加对 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);

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

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


0
投票

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "swal('Done !!!','User details saved successfully','success').then((value) => { window.location ='frmDisplayUsers.aspx'; });", true);

这就是答案。谢谢

© www.soinside.com 2019 - 2024. All rights reserved.