gpt4 book ai didi

c# - 在 IIS 中运行时无法显示消息框?

转载 作者:行者123 更新时间:2023-11-30 12:57:21 26 4
gpt4 key购买 nike

我想显示一个 OK/CANCEL 消息框。我是这样写的。

   if (MessageBox.Show("Are you sure you wants to Save the details ?  ", "Validate", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
// do something if "OK "
}

它在本地运行良好.. 但在 IIS 上显示错误“当应用程序未在 UserInteractive 模式下运行时显示模态对话框或表单不是有效操作。指定 ServiceNotification 或 DefaultDesktopOnly 样式以显示来自服务申请。”请帮忙。

最佳答案

要获得我相信您想要的效果,您需要使用 Javascript confirm()功能。它通常像这样使用:

<asp:Button runat="server" OnClientClick="return confirm('Are you sure you want to save the details?')" id="btnSubmit" OnClick="btnSubmit_Click" />

这将在单击按钮时显示一个确认框,如果用户单击“否”、“取消”等,该确认框将停止触发服务器 OnClick 事件。

OnClientClick将呈现为 onclick <input> 上的事件标签。其余部分由浏览器对 Javascript 的处理决定。参见 What's the effect of adding 'return false' to a click event listener?有关 OnClick 中代码的返回值的更多详细信息( OnClientClick ) 会。

这是使用 Chrome 的 confirm() 返回值的示例。对于第一次执行,我单击了取消。

JS confirm() example in Chrome)

关于c# - 在 IIS 中运行时无法显示消息框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18583781/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com