【问题标题】:confirmation message box in c# code behind [duplicate]c#代码后面的确认消息框[重复]
【发布时间】:2012-08-08 10:39:06
【问题描述】:

可能重复:
Confirmation message box in webapplication

我想在后面的代码中创建一个消息框。我的代码在这里。它没有显示任何消息框。请帮我这样做..

Button btn = new Button();
btn.OnClientClick = "return confirm('Your requested leave count exceeds the balance leave count.\n It may count as Loss of pay if your requeset approved by your head...\n \nAre you sure you wish to apply?');";
if (true)
{
  //Do something;
}
else
{
  //do something;
}

【问题讨论】:

  • 您是否将按钮添加到容器中?您在什么时候添加控件....在什么情况下。
  • 不,但我想在后面的 C# 代码中创建一个确认消息框..
  • 生硬,我需要这种类型的消息框。因为我在一个按钮点击中有两个功能。

标签: c# asp.net .net


【解决方案1】:

返回值仅在客户端可用 - 在 javascript 中 - 您确实应该在 ClientClick 事件上调用一个 javascript 函数,该函数将能够获取返回值并将其发送到您的服务器(可能使用AJAX)。

【讨论】:

  • 可以发示例代码吗。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-28
  • 2023-03-25
  • 2023-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多