网路上的资源:
https://www.bootcdn.cn/limonte-sweetalert2/6.10.3/
之後再新增一个 JS 档案 ,在里面添加以下内容 :
swal.setDefaults({
confirmButtonText: "确定", //确定按钮TEXT
cancelButtonText: "取消", //取消安纽TEXT
background: '#222629', //背景颜色
confirmButtonColor: '#5895BF', //确定按钮背景颜色
cancelButtonColor: '#626F75' //取消按钮背景颜色
});
//搭配 asp.net 的 button 元件使用
function sweetAlertConfirm(btn, t, s) {
if (btn.dataset.confirmed) {
btn.dataset.confirmed = false;
return true;
} else {
event.preventDefault();
swal({
title: t,
text: s,
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#5895BF',
cancelButtonColor: '#626F75',
confirmButtonText: '确定',
cancelButtonText: '取消'
})
.then(function () {
btn.dataset.confirmed = true;
btn.click();
}).catch(swal.noop);
}
}
//纯提示讯息框
function swalDialog(t, c, i) {
swal({
title: t,
html: c,
type: i,
confirmButtonText: "确定"
}).catch(swal.noop);
}
附注:如果还有其他个人设计可参考 参考网址里的内容~~
<head>
<link rel="stylesheet" href="css/sweetdialog.css" />
<script type="text/javascript" src="js/sweetdialog.js"></script>
<script type="text/javascript" src="js/JavaScript.js"></script>
</head>
public class SweetDialog
{
public enum MessageIcon : int
{
SUCCESS = 0,
FAIL,
WARNING,
INFO
}
//t = 标题文字 c = 内容 icon = 要显示的ICON p = 该网页
public void Show(Page p, String t, String c, int icon)
{
String info;
switch (icon)
{
case (int)MessageIcon.SUCCESS:
info = "success";
break;
case (int)MessageIcon.FAIL:
info = "error";
break;
case (int)MessageIcon.WARNING:
info = "warning";
break;
case (int)MessageIcon.INFO:
info = "info";
break;
default:
info = "question";
break;
}
string js = @"swalDialog('" + t + "', '" + c + "', '" + info + "');";
ScriptManager.RegisterStartupScript(p, GetType(), "script",
js, true);
}
}
范例 : (在想使用的地方输入以下程序码)
new SweetDialog().Show(this,"Title","Context",(int)SweetDialog.MessageIcon.INFO);
成功结果如下:
需要再 ASPX 里面 的 BUTTON 加入
<asp:Button ID="button" runat="server" Text="删除" OnClick = "button_Click"
OnClientClick="return sweetAlertConfirm(this,'确定要删除该笔资料吗?','');" />
protected void button_Click(object sender, EventArgs e)
{
//你要执行的动作
}
成功结果如下:
参考网址
https://dotblogs.com.tw/shadow/2017/10/17/130645
https://sweetalert2.github.io/#download
形式神经元变形 (原文网址:https://kknews.cc/tech/z34j3rg.html)...
说到学习资源,最容易学习的方式就是从母语开始 中文文章 Jerry Hong 的部落格 Jerry ...
看完这篇文章你会得到的成果图 与昨天一样,不过我们今天要谈一个 PyQt 中非常重要的 QThrea...
在经过了多日有一天没一天的研究、写Code与写作,今天假日花了一点时间将原本从Jupyter Not...
回合移动规则确立 今天主要在撰写/调整游戏的企划内容,在多日的思考後终於定下来移动的基本规则。 有别...