簡體   English   中英

jQuery模式與背后的代碼

[英]Jquery modal with code behind

我有個問題。 我想用以下代碼在模式彈出窗口中運行asp.net后面的輔助代碼。 但是我的研究並不十分成功。

您認為我應該如何執行流程?

<script type="text/javascript">
    function showAjaxModal() {
        jQuery('#Modal_Alert').modal('show', { backdrop: 'static' });

    }
</script>
<div class="modal fade" id="Modal_Alert">
    <div class="modal-dialog">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">
                    <asp:Label runat="server" ID="LblAlertHeader"></asp:Label></h4>
            </div>

            <div class="modal-body">
                <asp:Label runat="server" ID="LblAlertBody"></asp:Label>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Kapat</button>
                <%--<button type="button" class="btn btn-info">Save changes</button>--%>
            </div>
        </div>
    </div>
</div>

我想要做

if (true)
        {
            //open modal
        }
        else
        {
            //open modal
        }

代碼正在運行

<a href="javascript:;" onclick=" showAjaxModal(); " class="btn btn-default" >Show Me</a>

但是后面沒有工作代碼。

protected void BtnKaydet_Click(object sender, EventArgs e)
    { //openmodal; }

請幫忙。

將其添加到按鈕上,單擊后面的代碼

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "key", "showAjaxModal()", true);

使用下面的代碼它將起作用

                <script type="text/javascript">
                    function showAjaxModal() {
                       jQuery('#Modal_Alert').modal('show', { backdrop: 'static' });
                       return false;

                    }
                </script>
                 <asp:Button ID="BtnKaydet" runat="server" UseSubmitBehavior="false" OnClientClick="return showAjaxModal();" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM