ASP.Net按钮和jQuery PopUp表单

时间:2013-11-20 01:53:49

标签: jquery asp.net

以下是我用于“模态弹出窗体”的代码

$("[id*=btnFinish").live("click", function () {
    $("#timeLeft").dialog({
        title: "There's Time Left!!",
        open: function (event, ui) {
            $(".ui-dialog-titlebar-close").hide();
        },
        modal: true,
        draggable: false,
        resizable: false
    });
    return false;
});
} else {
    $("#timesUp").dialog({
        title: "Time is up!",
        open: function (event, ui) {
            $(".ui-dialog-titlebar-close").hide();
        },
        modal: true,
        draggable: false,
        resizable: false
    });
}

...

<div id="timesUp" style="display: none">
    Click proceed to start the first exam module.
    <br /><br />
<asp:Button ID="btnProce" runat="server" UseSubmitBehavior="false" Text="PROCEED" />
</div>
<div id="timeLeft" style="display: none">
You can go back, review your answers and change them if needed. Or you can continue to the next module and click Proceed.
<br /><br />
<asp:Button ID="btnBack" runat="server" UseSubmitBehavior="false" Text="BACK" />&nbsp;
<asp:Button ID="btnProceed" runat="server" UseSubmitBehavior="false" Text="PROCEED" />
</div>

在我的代码后面,div="timeLeft"如您所见,拥有两个按钮btnProceedbtnBackbtnProceedbtnProce中的div="timesUp"具有相同的功能。现在,我的问题是当显示div =“timeLeft”的模态弹出时,当用户点击btnBack时,我希望模式弹出窗口关闭并执行后面的代码。我真的不知道该怎么做。

1 个答案:

答案 0 :(得分:0)

添加

$("#btnBack").trigger('click');

在if语句下,它应该看起来像这样

$("[id*=btnFinish").live("click", function () {
    $("#timeLeft").dialog({
        title: "There's Time Left!!",
        open: function (event, ui) {
            $(".ui-dialog-titlebar-close").hide();
            $("#btnBack").trigger('click');
        },
        modal: true,
        draggable: false,
        resizable: false
    });
    return false;
});
} else {
    $("#timesUp").dialog({
        title: "Time is up!",
        open: function (event, ui) {
            $(".ui-dialog-titlebar-close").hide();
        },
        modal: true,
        draggable: false,
        resizable: false
    });
}