2011-12-29 23 views
0

我有一個適當的OnClick的asp:按鈕。我也有一個jQuery UI對話框,當點擊按鈕時打開。當用戶在對話框中單擊「是」時,將會調用類似於OnClick函數的。如果一個代碼隱藏功能被稱爲「是」,而另一個代碼被稱爲「否」,則更好。但對於我的生活,我無法弄清楚如何。根據jQuery對話結果調用OnClick for asp:按鈕

這裏是我當前的代碼:

$(function() { 
    $("#dialog:ui-dialog").dialog("destroy"); 
    $("#dialog-confirm").dialog({ 
      autoOpen:false, 
      resizable:false, 
      height:175, 
      width: 450, 
      modal:true, 
      buttons: { 
       "Yes": function() { 

        $(this).dialog("close"); 
       }, 
       "No": function() { 
        $(this).dialog("close"); 
       } 
      } 

     }); 


    $(".navigation").click(function(e) { 
     e.preventDefault(); 
     $("#dialog-confirm").dialog('open'); 

    }); 
}); 

和按鈕:

<asp:Button ID="testerE" class="navigation" runat="server" OnClick="JustATest" Text="Test me" /> 

回答

0

你爲什麼不把這些按鈕的DIV中並用其作爲一個顯示在模態的HTML對話?

<div id="my-placeholder-for-dialog"> 
    Text goes here 
    <asp:Button ID="testerE" class="navigation" runat="server" OnClick="JustATest" Text="Test me" /> 
</div> 

否則,您需要調用頁面上存在的__doPostBack函數。

+0

仍然不會在對話框中單擊時運行代碼。

You are navigating away from this banner-IPG, do you want to save any changes?

ScottieB 2011-12-29 00:38:42

+0

呈現的HTML如何顯示? – Khanzor 2011-12-29 00:46:59

+0

原來我遺漏了一個至關重要的步驟:http://stackoverflow.com/questions/757232/jquery-ui-dialog-with-asp-net-button-postback – ScottieB 2011-12-29 00:53:48

相關問題