2012-09-14 27 views
0

我想創建一個確認框,當用戶想要刪除他的帳戶,因爲他需要插入他的密碼(在文本框中)。但我不知道如何捕捉到回發事件和背後的代碼執行方法...
這是我的代碼:用文本框確認對話框回發

我的對話框:

<div id="dialog" title="Confirmation Required"> 
    Are you sure about this? 
    Password:<asp:TextBox id="remove_password" TextMode="Password" runat="server"></asp:TextBox> 
</div> 

我的按鈕誰調用對話:

<asp:LinkButton ID="lb_remove" Text="Delete Account" runat="server" OnClientClick="javascript: $('#dialog').dialog('open'); return false;" ClientIDMode="Static" /> 

我的腳本:

$().ready(function() { 
     $("#dialog").dialog({ 
      autoOpen: false, 
      modal: true, 
      bgiframe: true, 
      width: 400, 
      height: 300, 
      buttons: { 
       'Delete': function() { 
        //do something 

        //what to put here??? 
        //i need to pass my textbox value or in 
        //codebehind i do findcontrol and will work? 
        // 
       }, 
       'Cancel': function() { 
        $(this).dialog('close'); 
       } 
      } 
     }) 
    }); 

人幫我?謝謝。

回答

0

你不能這樣做,你的對話框會彈出同時回傳會executed.You不能在自己的控制這一點,如果你正在嘗試做的,在你的代碼behind.At最你可以只使用

return confirm('Are you sure you want to Delete?'); 

其他解決方法是依靠Javascript/Ajax這個。

編輯:

試試這個

<asp:LinkButton ID="lb_remove" Text="Delete Account" runat="server" OnClientClick="return confirm('Are you sure you want to delete?');" ClientIDMode="Static" /> 
+0

我不能?如果我把這個<%= this.Page.ClientScript.GetPostBackEventReference(new PostBackOptions(this.lb_remove))%>;會做出回發,但我不知道如何捕捉此事件:S – oteal

+0

@ user1546424顯示您遇到問題的位置? – freebird

+0

當用戶點擊刪除時,我需要做什麼? – oteal