2012-08-08 148 views
-5

可能重複:
Confirmation message box in webapplication確認消息框背後

我想在代碼中創建一個消息框後面。我的代碼在這裏。它不顯示任何消息box.Please幫我做..

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

您是否將按鈕添加到容器?在什麼時候加入控制......在什麼情況下。 – DaveHogan 2012-08-08 10:40:26

+0

http://stackoverflow.com/questions/11861271/confirmation-message-box-in-webapplication/11861387#11861387 – Curt 2012-08-08 10:40:39

+0

不,但我想在C#代碼後面創建一個確認消息框.. – 2012-08-08 10:41:31

回答

2

的返回值將是僅適用於客戶端 - 在JavaScript - 你真的應該叫上ClientClick事件的JavaScript函數,它將能夠獲取返回值並將其發送到您的服務器(可能使用AJAX)。

+0

您可以發送示例代碼。 – 2012-08-08 10:46:19