“返回”按钮到之前的Modal Popup(Ajax Modal Popup Extender)

时间:2013-01-16 11:15:19

标签: c# javascript asp.net html

我的Default.aspx上有一个按钮,用于启动“条款和条件”模式弹出窗口(popup1)。然后我在模态弹出窗口上有一个按钮,它在顶部启动另一个模态弹出窗口(popup2)(我的条款和条件的第2页)。

我想向modalpopup2添加一个后退按钮,它关闭popup2并显示modalpopup1,以便用户从popup2获得'forward / back'选项。

我添加了'ButtonBack'并试过......

protected void ButtonBack_Click(object sender, EventArgs e)
{

    Popup1.Show();
}

但这只是重定向回我的default.aspx。有关如何使用C#或某些javascript解决此问题的任何想法?

由于

2 个答案:

答案 0 :(得分:0)

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script type="text/javascript" language="javascript">
        function fn_Next() {
            $find(ModalPopupExtender1).hide();
            $find(ModalPopupExtender2).show();
        }

        function fn_Next1() {
            $find(ModalPopupExtender2).hide();
            $find(ModalPopupExtender3).show();
        }

        function fn_Back() {
            $find(ModalPopupExtender2).hide();
            $find(ModalPopupExtender1).show();
        }

        function fn_Back1() {
            $find(ModalPopupExtender3).hide();
            $find(ModalPopupExtender2).show();
        }
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">    

    <script type="text/javascript" language="javascript">
        var ModalPopupExtender1 = '<%= ModalPopupExtender1.ClientID %>';
        var ModalPopupExtender2 = '<%= ModalPopupExtender2.ClientID %>';
        var ModalPopupExtender3 = '<%= ModalPopupExtender3.ClientID %>';
    </script>

    <asp:Button ID="btnShowPopup" Text="Show Popup" runat="server" />
    <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup"
        PopupControlID="panelPopup1" BackgroundCssClass="bkgPopup" OkControlID="btnNext" OnOkScript="fn_Next()">
    </asp:ModalPopupExtender>

    <asp:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="panelPopup2"
        PopupControlID="panelPopup2" BackgroundCssClass="bkgPopup" OkControlID="btnBack" OnOkScript="fn_Back()"
            CancelControlID="btnNext1" OnCancelScript="fn_Next1()">
    </asp:ModalPopupExtender>

    <asp:ModalPopupExtender ID="ModalPopupExtender3" runat="server" TargetControlID="panelPopup3"
        PopupControlID="panelPopup3" BackgroundCssClass="bkgPopup" OkControlID="btnBack1" OnOkScript="fn_Back1()">
    </asp:ModalPopupExtender>

    <asp:Panel ID="panelPopup1" runat="server" CssClass="panelPopup">
        <div>
            <table>
                <tr>
                    <td>Popup 1</td>
                </tr>
            </table>            
        </div>
        <div>
            <asp:Button ID="btnNext" runat="server" Text="Next" />
        </div>        
    </asp:Panel>

    <asp:Panel ID="panelPopup2" runat="server" CssClass="panelPopup">
        <div>
            <table>
                <tr>
                    <td>Popup 2</td>
                </tr>
            </table>            
        </div>
        <div>
            <asp:Button ID="btnBack" runat="server" Text="Back" />
            <asp:Button ID="btnNext1" runat="server" Text="Next" />
        </div>        
    </asp:Panel>

    <asp:Panel ID="panelPopup3" runat="server" CssClass="panelPopup">
        <div>
            <table>
                <tr>
                    <td>Popup 3</td>
                </tr>
            </table>            
        </div>
        <div>
            <asp:Button ID="btnBack1" runat="server" Text="Back" />
        </div>        
    </asp:Panel>
</asp:Content>

答案 1 :(得分:0)

感谢您的帮助!

这是我的最终剧本......

    <script type="text/javascript" language="javascript">
    function fn_Next(sender, args) {
        $find('ModalTerms1').hide();
        $find('ModalTerms2').show();
    }

    function fn_Back(sender, args) {
        $find('ModalTerms2').hide();
        $find('ModalTerms1').show();

}

    function fn_Last(sender, args) {
        $find('ModalTerms3').hide();
        $find('ModalTerms1').hide();
        $find('ModalTerms2').show();
    } 

</script>