简体   繁体   中英

Modalpopupextender closing while click on “OK” button

I'm using a Modalpopupextender ajax control to popup a panel. In the panel have two buttons, one is Asp button (btnOk) and one is normal html button (btnCancel). While click on the OK the popup panel closing, but I don't want to close the popup panel while click on the Ok button, popup should close only while click on the cancel button. How I can stop the Ok button to close the popup panel. please find the code snippet below

        <ATK:ModalPopupExtender
            BackgroundCssClass="ModalPopupBG"
            DropShadow="true"
            OkControlID="btnOkay"                
            CancelControlID="btnCancel"
            runat="server"
            PopupControlID="AddTopic"
            id="ModalPopupExtender1" 
            OnOkScript="onOk()"                           
            TargetControlID="btnAddNew"/> 



<asp:Panel ID="AddTopic" runat="server"  CssClass="popup_Container"  >           
        <div class="popup_Titlebar" id="PopupHeader">
            <div class="TitlebarLeft">
                Add New Topic
            </div>
            <div class="TitlebarRight" onclick="cancel();">
            </div>
        </div> 
        <div class="popup_Body">                      
            <asp:Label ID="lblTopic" runat="server" Text="Topic Name"> </asp:Label>
            <asp:TextBox ID="tbTopicName" runat="server" Width="400px" ></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ErrorMessage="*" ControlToValidate="tbTopicName">
            </asp:RequiredFieldValidator>
            <br /> <br />  
            <span style="padding-left:350px"> 
                <asp:Button ID="btnDone" runat="server" Text="Done" onclick="btnDone_Click" 
                UseSubmitBehavior="False"/>  
                <input id="btnCancel" value="Cancel" type="button" OnClick="cancel();"/>                     
            </span>                 
        </div>

        <div class="popup_Buttons" style="display: none">
            <input id="btnOkay" value="Done" type="button" />         
        </div>        
    </asp:Panel>

Add to the end of btnDone_Click method following instruction: ModalPopupExtender1.Show();

Remove the property "OkControlID" from the ModalPopupExtender.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM