OK Click OK to not shoot?

I have a button inside UpdatePanel. The button is used as the OK button for ModalPopupExtender. For some reason, the button press event does not fire. Any ideas? Did I miss something?

<asp:updatepanel id="UpdatePanel1" runat="server"> <ContentTemplate> <cc1:ModalPopupExtender ID="ModalDialog" runat="server" TargetControlID="OpenDialogLinkButton" PopupControlID="ModalDialogPanel" OkControlID="ModalOKButton" BackgroundCssClass="ModalBackground"> </cc1:ModalPopupExtender> <asp:Panel ID="ModalDialogPanel" CssClass="ModalPopup" runat="server"> ... <asp:Button ID="ModalOKButton" runat="server" Text="OK" onclick="ModalOKButton_Click" /> </asp:Panel> </ContentTemplate> </asp:updatepanel> 
+42
asp.net-ajax updatepanel modalpopupextender
Sep 27 '08 at 0:38
source share
8 answers

Aspx

 <ajax:ModalPopupExtender runat="server" ID="modalPop" PopupControlID="pnlpopup" TargetControlID="btnGo" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btnCancel" X="470" Y="300" /> //Codebehind protected void OkButton_Clicked(object sender, EventArgs e) { modalPop.Hide(); //Do something in codebehind } 

And do not set the OK button as OkControlID.

+51
Jul 22 '09 at 17:23
source share

It looks like the button that is used as the OK or CANCEL button for ModalPopupExtender cannot have a click event. I checked this by removing

 OkControlID="ModalOKButton" 

from the ModalPopupExtender tag, and the button click starts. I need to figure out another way to send data to the server.

+9
Sep 27 '08 at 1:00
source share

It may also be that the button should have CausesValidation = "false". It worked for me.

+7
Jun 10 '09 at 12:18
source share

I was just looking for a solution for this :)

it looks like you cannot assign OkControlID to the control, if you want this control to fire an event, just by deleting this property, I got everything working again.

my code (working):

 <asp:Panel ID="pnlResetPanelsView" CssClass="modalPopup" runat="server" Style="display:none;"> <h2> Warning</h2> <p> Do you really want to reset the panels to the default view?</p> <div style="text-align: center;"> <asp:Button ID="btnResetPanelsViewOK" Width="60" runat="server" Text="Yes" CssClass="buttonSuperOfficeLayout" OnClick="btnResetPanelsViewOK_Click" />&nbsp; <asp:Button ID="btnResetPanelsViewCancel" Width="60" runat="server" Text="No" CssClass="buttonSuperOfficeLayout" /> </div> </asp:Panel> <ajax:ModalPopupExtender ID="mpeResetPanelsView" runat="server" TargetControlID="btnResetView" PopupControlID="pnlResetPanelsView" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btnResetPanelsViewCancel" /> 
+6
Dec 21 '08 at 0:00
source share

Place the attribute "UseSubmitBehavior = false" in the Button-Control.

+3
Feb 12 2018-10-12
source share

I often use an empty shortcut like TargetControlID. ex. <asp:Label ID="lblghost" runat="server" Text="" />

I saw two things that caused the click event to fail:
1. you need to remove OKControlID (as others pointed out)

2. If you use field validators, you must add CausesValidation = "false" to the button.

Both scenarios behaved the same for me.

+3
Nov 24 '10 at 18:09
source share

None of the previous answers worked for me. I called the button postback on the OnOkScript event.

 <div> <cc1:ModalPopupExtender PopupControlID="Panel1" ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" OkControlID="Ok" OnOkScript="__doPostBack('Ok','')"> </cc1:ModalPopupExtender> <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton> </div> <asp:Panel ID="Panel1" runat="server"> <asp:Button ID="Ok" runat="server" Text="Ok" onclick="Ok_Click" /> </asp:Panel> 
+2
Jan 28 '09 at 11:17
source share

I found a way to test modalpopup without postback.

In ModalPopupExtender, I installed OnOkScript in a function, for example ValidateBeforePostBack (), and then in the function that I call Page_ClientValidate for the validation group that I want, run the validation and if it fails, save the display of the modal message. If it passes, I call __doPostBack .

 function ValidateBeforePostBack(){ Page_ClientValidate('MyValidationGroupName'); if (Page_IsValid) { __doPostBack('',''); } else { $find('mpeBehaviourID').show(); } } 

Hope this helps.

+1
Jun 09 '16 at 1:07 on
source share



All Articles