Modalpopupextender关闭,同时单击“确定”按钮

时间:2011-07-07 10:04:40

标签: c# asp.net ajax modalpopupextender

我正在使用Modalpopupextender ajax控件来弹出面板。在面板上有两个按钮, 一个是Asp按钮(btnOk),一个是普通的html按钮(btnCancel)。单击OK弹出式面板关闭,但我不想在单击Ok按钮时关闭弹出式面板,只有在单击cancel按钮时才会关闭弹出窗口。如何停止Ok按钮关闭弹出面板。请找到下面的代码段

        <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>

2 个答案:

答案 0 :(得分:4)

按照以下说明添加到btnDone_Click方法的末尾:ModalPopupExtender1.Show();

答案 1 :(得分:2)

从ModalPopupExtender中删除属性“OkControlID”。