我有一个甜蜜的问题。我单击删除但警告消息查找问题
function checkDelete() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function () {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
});
}
<asp:LinkButton ID="lbDelete" runat="server" OnClientClick="checkDelete();return false;">Delete</asp:LinkButton>
答案 0 :(得分:0)
<script type="text/javascript">
function onSessionExpire(msgtxt) {
swal({
title: "",
text: msgtxt,
type: "error",
showCancelButton: false,
confirmButtonColor: "#008b8b",
confirmButtonText: "OK",
cancelButtonText: "",
closeOnConfirm: true,
closeOnCancel: true
},
function (isConfirm) {
if (isConfirm) {
//swal("Deleted!", "Your imaginary file has been deleted.", "success");
setTimeout(function () { window.location.href = 'frmLogin.aspx' }, 1);
} else {
//swal("Cancelled", "Your imaginary file is safe :)", "error");
setTimeout(function () { window.location.href = 'frmLogin.aspx' }, 1);
}
});
}
</script>
答案 1 :(得分:0)
我使用另一种方法。 首先创建一个Basewebform.cs
public class BaseWebForm : System.Web.UI.Page
private void Page_Load(object sender, System.EventArgs e)
{
string baseUrl = Request.Url.Scheme + "://" +
Request.Url.Authority +
Request.ApplicationPath.TrimEnd('/') +
"/";
string jspath1 = baseUrl + "sweetalert/sweetalert2.min.css";
string jspath2 = baseUrl + "sweetalert/sweetalert2.min.js";
string jspath3 = baseUrl + "sweetalert/swalerthelper.js"; // this is my helper
string jspath4 = baseUrl + "sweetalert/polyfill.min.js";
//register css
HtmlLink styleLink = new HtmlLink();
styleLink.Attributes.Add("rel", "stylesheet");
styleLink.Attributes.Add("type", "text/css");
styleLink.Href = jspath1;
this.Page.Controls.Add(styleLink);
//register sweetalert js
ClientScript.RegisterClientScriptInclude("jscript2", jspath2);
ClientScript.RegisterClientScriptInclude("jscript3", jspath3);
ClientScript.RegisterClientScriptInclude("jscript4", jspath4);
}
//swalerthelper.js
// it will overwrite the default browser alert() function.
function alert(msg, msgtype) {
msgtype = msgtype || 'warning';
var tmp = msg.toLowerCase();
if (tmp.indexOf('save')>0 || tmp.indexOf('success')>0){
msgtype ='success';
}
if (tmp.indexOf('error')>0 || tmp.indexOf('fail')>0){
msgtype ='error';
}
Swal({
text: msg,
type: msgtype,
confirmButtonText: 'OK',
confirmButtonColor: '#566573'
})
}
那。玩得开心