c#代码隐藏中的确认消息框

c#代码隐藏中的确认消息框,c#,asp.net,.net,C#,Asp.net,.net,可能重复: 我想在代码隐藏中创建一个消息框。我的密码在这里。它不显示任何消息框。请帮助我完成此操作 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 \

可能重复:

我想在代码隐藏中创建一个消息框。我的密码在这里。它不显示任何消息框。请帮助我完成此操作

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;
}

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

您是否将该按钮添加到容器中?在什么时候添加控件。。。。在什么情况下。不,但我想在C#code behind中创建一个确认消息框。curt,我需要这种类型的消息框。因为我有两个功能在一个按钮点击。你可以发送示例代码。