在这里阅读了多篇帖子并试图让我的代码工作没有什么真正帮助我。我想要完成的是当用户单击对话框消息中的“确定”按钮时从noty获取返回值。我希望在C#代码隐藏中获得该值并继续使用更多逻辑。 Messagingialog正在按预期工作和显示,但是当用户单击确定时我无法弄清楚如何获得真/假。提前谢谢!
<asp:Button ID="btnInactivate" runat="server" Text="Inactivate" OnClick="btnInactivate_Click" Visible="false" CssClass="buttonInactivate"/>
protected void btnInactivate_Click(object sender, EventArgs e)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "script", "confirm_noty();", true);
var retValue = noty........
// get the value from noty
// button ok pressed ... continue with further process....
}
function confirm_noty() {
var n = noty({
layout: 'center',
type: 'warning',
text: 'Do you want to inactivate current record?',
dismissQueue: true,
theme: 'defaultTheme',
modal: true,
buttons: [
{
addClass: 'btn btn-primary', text: 'Ok', onClick: function ($noty) {
// this = button element
// $noty = $noty element
$noty.close();
noty({
dismissQueue: true, force: true, layout: 'center', theme: 'defaultTheme', text: 'Record successfully inactivated.', type: 'success',
"animateClose": { "height": "toggle" }, "speed": "550", "timeout": "1200", "closable": true, "closeOnSelfClick": true
});
}
},
{
addClass: 'btn btn-danger', text: 'Cancel', onClick: function ($noty) {
$noty.close();
}
}
]
});
}