如何重置ModalPopupExtender?

时间:2013-04-08 14:14:43

标签: c# asp.net ajax

我有一个ModalPopUpExtender,点击取消按钮,它应该重置原始形式的ModalPopUpExtender,就像在Page_Load期间一样。 任何帮助将受到高度赞赏

2 个答案:

答案 0 :(得分:0)

<强> ASPX:

<head id="Head1" runat="server">
    <title>Modal Popup</title>
    <style type="text/css">
        .modalStyle
        {
            background-color: Gray;
            filter: alpha(opacity=70);
            opacity: 0.7;
        }

        .panelStyle
        {
            width: 300px;
            height: 180px;
            border: 2px solid Gray;
            background-color: White;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="btnShow" runat="server" Text="Show" />
    <asp:ToolkitScriptManager ID="scripManager" runat="server" />
    <asp:ModalPopupExtender ID="modal" BackgroundCssClass="modalStyle" PopupControlID="popup" TargetControlID="btnShow" runat="server" />
    <asp:Panel runat="server" ID="popup" CssClass="panelStyle">
        <div>
            <asp:Button ID="btnCancel" runat="server" OnClick="HideModal" Text="Cancel" />
        </div>
    </asp:Panel>
    </form>
</body>

代码背后:

protected void HideModal(object sender, EventArgs e)
{
    System.Diagnostics.Debugger.Break();
    modal.Hide();
    //Execute the reset logic
}

答案 1 :(得分:0)

点击取消按钮时隐藏ModelPopupExtender,需要在CancelControlID控件中使用ModalPopupExtender属性。