2012-10-24 87 views
2

我有一個模式彈出式擴展器,它觸發按鈕單擊...現在不管onclientclick函數返回值是true/false它總是彈出。我需要停止模式來觸發返回false和模態來觸發返回true ..如何執行此操作?Stop ModalPopup Extender to popup

請找到下面的代碼:

<div style="text-align:center;" runat="server" id="pnlButton">   
    <asp:Button CssClass="button" ID="btnBack" runat="server" Text="Back" 
     Width="120px" onclick="btnBack_Click" UseSubmitBehavior="false" /> 
    &nbsp; 
    <asp:Button CssClass="button" ID="btnCancel" runat="server" 
      Text="Cancel Request" Width="130px" onclick="btnCancel_Click" onClientClick="Validate();" /> 
</div> 
<div style="text-align:center;"> 
<asp:Button CssClass="button" ID="btnDone" Visible="false" runat="server" 
     Text="Done" Width="110px" onclick="btnDone_Click" /> 
</div> 

<ajaxToolkit:ConfirmButtonExtender ID="cbe" runat="server" 
TargetControlID="btnCancel" 
DisplayModalPopupID="ModalPopupExtender1" 
ConfirmText="Are you sure you want to click this?" /> 
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnCancel" 
PopupControlID="PNL" OkControlID="ButtonOk" CancelControlID="ButtonCancel" BackgroundCssClass="modalBackground" /> 
<asp:Panel ID="PNL" runat="server" Style="display: none; width: 400px; background-color: White; 
    border-width: 2px; border-color: Black; border-style: solid; padding: 20px;"> 
    <h2>Are you sure you want to cancel this request?</h2> 
    <br /> 
    <br /> 
    <div style="text-align: right;"> 
     <asp:Button ID="ButtonOk" runat="server" Text="Yes" CssClass="button" />&nbsp;&nbsp; 
     <asp:Button ID="ButtonCancel" runat="server" Text="No" CssClass="button" /> 
    </div> 
</asp:Panel> 
+0

我沒有看到任何地方的OnClientClick。看起來像一個JavaScript確認也會更容易實施。 – awright18

+0

我忘記了忘記放 – PeteEngineer

+0

在什麼情況下你不想驗證它? – awright18

回答

0

您可以打開JavaScript彈出

function ValidateAndOpen(){ 
if(Validate()){ 
var modalDialog = $find("ModalPopupExtender1"); 
// get reference to modal popup using the AJAX api $find() function  
    if (modalDialog != null) { 
    modalDialog.show(); 
    }  
} 
return false; 
} 

您必須設置的ClientIDMode =「靜「在ModalPopupExtender 並設置OnClientClick =」返回ValidateAndOpen();「

+0

我會試試這個! – PeteEngineer

0

改變你的代碼如下

onClientClick="return Validate();" 
+0

我曾嘗試過,它不工作...仍然它的火災返回真假 – PeteEngineer

0

把這個腳本到您的形式:

function pageLoad(sender, args) { 
     if (args.get_isPartialLoad() === false) { 
      $find("<%= ModalPopupExtender1.ClientID %>").add_showing(function (sender, args) { args.set_cancel(Validate()); }); 
     } 
} 
+0

編譯錯誤 說明:編譯服務此請求所需的資源時發生錯誤。請查看以下具體的錯誤細節並適當修改您的源代碼。 – PeteEngineer

+0

編譯器錯誤消息:CS0120:對於非靜態字段,方法或屬性'System.Web.UI.Control.ClientID.get' 需要對象引用第34行:函數pageLoad(sender,args){0}35行:if(args.get_isPartialLoad()=== false){第36行︰$ find(「<%= ModalPopupExtender.ClientID%>」)。add_showing(function(sender,args){args.set_cancel(ValidateControl()) ;}); 37行:} 38行:} – PeteEngineer

+0

@PeteEngineer,我有固定的腳本 –

相關問題