2012-06-07 52 views
1

我正在使用Asp.Net/C#,我有一個要求,在提交數據前我要顯示確認,如果用戶單擊確定按鈕,則繼續,否則取消提交。我知道javascript確認框這樣做,但在我的情況下,我需要顯示我自己的彈出窗口,任何人都可以建議我如何實現這一點。我不想在這裏使用任何插件。 感謝您的任何建議。如何在提交信息前顯示彈出窗口

+0

參考http://www.codingforums.com/showthread.php?t=117405 –

+0

使用'OnClientClick'? – mshsayem

回答

1

您可以創建如下:

function createPopup() { 
    //Get the data from the form fields 
    var background = document.custom.back.value; 
    var title = document.custom.title.value; 
    var text = document.custom.text.value; 

    //Now create the HTML code that is required to make the popup 
    var content = "<html><head><title>"+title+"</title></head>\ 
<body bgcolor='"+background+"'><h1>"+title+"</h1>"+text+"<br />\ 
<a href='javascript:window.close()'>Close the popup</a></body></html>"; 

    //Create the popup 
    var popup = window.open("","window","resizeable,width=400,height=300"); 
    popup.document.write(content); //Write content into it. 
    pops.document.close(); 
} 

邏輯想如下:我沒有執行,測試只看到邏輯忽略MINORE錯誤,如果任何..還設置佈局,邊框看起來像確認窗口。

function popup() { 
    alert('popup called'); 

    //Now create the HTML code that is required to make the popup 
    var content = "<html><head><title>ConfirmBox</title></head><body >Do you want to continue ? <br /> 
    <input type='button' value='ok' onclick='return true'/> 
    <input type='button' value='cancel' onclick='return false'/> <a href='javascript:window.close()'>Close the popup</a></body></html>"; 

    //Create the popup 
    var popup = window.open("","window","resizeable,width=400,height=300"); 
    popup.document.write(content); //Write content into it. 
    pops.document.close(); 
} 

參考http://www.openjs.com/tutorials/advanced_tutorial/popup.php

+0

這不會作爲一個確認窗口...;) – walther

+0

我剛剛在窗口中顯示的方式,他可以返回虛假和真實取決於在其機構中創建按鈕的點擊.. –

+0

我知道,但我認爲這正是他遇到麻煩的部分。打開窗戶不應該是一個問題。 – walther