2011-04-27 37 views
1

如何在我的代碼下面有確認按鈕? (是 - 取消)確認按鈕中的JavaScript功能?

ClientScript.RegisterStartupScript(typeof(Page), "key", "<script>alert('There is an exiting Insurance code. Are you sure do you want to Edit it?');</script>"); 

我想這一個,但它不工作..

ClientScript.RegisterStartupScript(typeof(Page), "key", "if(!confirm('There is an existing insurance code . Do you want to edit?'))return false;"); 

的感謝!

+0

警報/確認/提示窗口上的負載是可怕的。請不要使用它們。 – ThiefMaster 2011-04-27 06:12:41

回答

0

使用confirm函數。

這也許值得一提的是,可用性原則經常在此

編輯可能是一些沿

if (confirm('There is an exiting Insurance code.' + "\n" + "Are you sure you want to Edit it?")) 
    ClientScript.RegisterStartupScript(typeof(Page)); 
2

使用JavaScript confirm行對話框,而不是警告皺眉。

function confirmation() { 
    var answer = confirm("There is an exiting Insurance code. 
      Are you sure do you want to Edit it?") 
    if (answer){ 
     alert("You clicked OK."); 
    } 
    else{ 
     alert("You clicked Cancel."); 
    } 
}