Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
asp.net SweetAlert不工作_Asp.net_Sweetalert - Fatal编程技术网

asp.net SweetAlert不工作

asp.net SweetAlert不工作,asp.net,sweetalert,Asp.net,Sweetalert,我有个问题。我单击“删除”,但警告消息看起来有问题 function checkDelete() { swal({ title: "Are you sure?", text: "You will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonColor: "

我有个问题。我单击“删除”,但警告消息看起来有问题

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>
函数checkDelete(){
游泳({
标题:“你确定吗?”,
text:“您将无法恢复此虚拟文件!”,
键入:“警告”,
showCancelButton:true,
confirmButtonColor:#DD6B55“,
confirmButtonText:“是的,删除它!”,
closeOnConfirm:false
},函数(){
swal(“已删除!”,“您想象的文件已被删除。”,“成功”);
});
}
删除


函数onSessionExpire(msgtxt){
游泳({
标题:“,
文本:msgtxt,
键入:“错误”,
showCancelButton:false,
confirmButtonColor:#008b8b“,
confirmButtonText:“确定”,
cancelButtonText:“”,
closeOnConfirm:true,
closeOnCancel:对
},
功能(isConfirm){
如果(我确认){
//swal(“已删除!”,“您想象的文件已被删除。”,“成功”);
setTimeout(函数(){window.location.href='frmLogin.aspx'},1);
}否则{
//swal(“已取消”,“您的虚拟文件是安全的:)”,“错误”);
setTimeout(函数(){window.location.href='frmLogin.aspx'},1);
}
});
}
我使用另一种方法。 首先创建一个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'

        })
 }

就是这样。玩得开心

浏览器的JavaScript控制台窗口/web inspector中显示了什么?今天遇到了同样的问题-忘记了包含sweetalert css…抱歉,忘了说,所有web表单,只要从基本表单继承即可。因此所有继承的表单都将具有SweetAlert功能,
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'

        })
 }