ScriptManager.RegisterStartupScript(this, this.GetType(),
"alert",
"alert('User details saved successfully');window.location ='frmDisplayUsers.aspx';",
true);
您需要在页面的 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);
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "swal('Done !!!','User details saved successfully','success').then((value) => { window.location ='frmDisplayUsers.aspx'; });", true);
这就是我想要的......
<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);
这就是答案。谢谢