make bootstrap模态弹出窗口表现得像警报asp.net

时间:2017-10-04 06:27:33

标签: jquery asp.net twitter-bootstrap modal-dialog

我想在PageLoad()事件上显示一个模态弹出窗口,但问题是当模态弹出窗口显示时,在后台页面已经加载并且无法像正常警报一样停止加载

<div class="modal fade" id="myModal" runat="server">
    <div class="modal-dialog">
        <div class="modal-content" style="width: 400px; margin: 0 auto;">
            <div class="modal-header" runat="server">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">
                    <label id="lblMasterMessage"></label>
                </h4>
            </div>
            <div class="modal-body">
                <label id="lblMasterbodyMessage"></label>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" runat="server">Close</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    function openModals(message, header, url) {
        $(<%= myModal.ClientID%>).modal('show');
        $('#lblMasterMessage').html(header);
        $('#lblMasterbodyMessage').html(message);
        //alert(message);
        $('#myModal').on('hidden.bs.modal', function (e) {
            if (url != '') {
                window.location = url;
                Console.log("done");
            }
        });
    }
</script>

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        string message = "Processing Can Only Be Done On Month Last Effective Day!!";
        string header = "Info";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "LaunchServerSide", "openModals('" + message + "','" + header + "','BusinessHomePage.aspx');", true);
    }
}

0 个答案:

没有答案